[bigint] Hex numbers...
    Matt McCutchen <matt at mattmccutchen.net>
    
    Thu Mar 26 17:02:44 PDT 2009
    
    
  
On Thu, 2009-03-26 at 17:35 -0400, Niakam Kazemi wrote:
> I would like to use your library for a project I am working on.
> However, I am not able to use string inputs representing Hex numbers.
> Would you be able to provide an example? The following correctly
> prints 15. However, if tVal = "ff" the result is 165 vs. 255. Maybe
> there is an explanation that I am missing. I appreciate your help.
> Thanks, Niakam K.
>  
> std::string tVal = "f";
> BigUnsigned t;
> t = stringToBigUnsigned(tVal);
> std::cout << t << std::endl;
"stringToBigUnsigned" works in base 10; the fact that it is accepting
"f" is a bug that I will fix when I get a chance.  To parse a string in
base 16, you have to use the underlying BigUnsignedInABase class:
std::string tVal = "ff";
BigUnsigned t;
t = BigUnsigned(BigUnsignedInABase(tVal, 16));
std::cout << t << std::endl;
-- 
Matt
    
    
More information about the bigint
mailing list