Rounding

Hi guys. I'm really new to ttmath, just downloaded it today. I was wondering if it is possible to round a floating number (stored in Big) to an unsigned int (Uint).

Example:

ttmath::Big<1,5> a = 0.123452
ttmath::Uint<5> b;
//This should give 12.3452
a = a*100;
b = (ttmath::Uint<5>)(a);
//I want b to store 12.

Right now I get the type cast error. Can anyone enlighten me on how this can be done? I'd really appreciate it. Thanks.

Added by: ~AnimaSolo, 2013 III 19

Nvm scratch that. I found out how to do it thanks.

Added by: ~AnimaSolo, 2013 III 19

Found another problem.

Anyway here's what I need to do.

I have a long float number like:
0.12417359178395710348012948102948124

I wish to convert it into an integer:
12417359178395710348012948102948124

Then I wish to display it in hexadecimal format.
Through my testing, it seems like the UInt<> variable can perform the conversion into hexadecimal, but Big<><> cannot. But I need to use Big<><> to handle the long float number in the first place.

Any ideas guys?

Added by: tomek, 2013 III 19

ttmath::Big<1,5> a = 12.3452;

// converting to Int
ttmath::Int<5> b = a.ToInt();

// display Int in hex
std::cout << b.ToString(16) << std::endl;
// b.ToString() returns std::string

// display Big in hex
std::cout << a.ToString(16) << std::endl;

Added by: ~AnimaSolo, 2013 III 20

Thanks a lot!