Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

numeric type conversions

Dear all,

I am looking for some code samples before trying to reinvent the wheel. I need to convert from several numeric types to other numeric types. I mean,

from char to int
from int to char
from unsigned int to int
from int to unsigned int
...
from float to int
from int to float.
..and more of these kind.

I need to check that no overflows underflows happen, using asserts. So I am looking for some code sample that can do what I need.

I am also looking for a string to numeric(int, char, float) and numeric to string converter.

I would appreciate any info,

thanks a lot and best regards,

otomi
[690 byte] By [otomi] at [2007-11-11 8:30:05]
# 1 Re: numeric type conversions
This sounds like an assignment which is best left for you to figure out. This is basic primitive data type stuff, and it is important that you understand the stuff which you should figure out by trying to code these examples yourself rather than being fed by someone else (not teaching you a thing).
nspils at 2007-11-11 21:01:17 >
# 2 Re: numeric type conversions
I second that, however I will point at atoi and atof functions.
jonnin at 2007-11-11 21:02:23 >