hi everyone,
i want to convert a floating point number to an IEEE32 bit standart. first, i tried to split the float number.
here is the code;
float number = float.Parse(Console.ReadLine());
int a = (int)number;
float b= number - a;
Console.WriteLine(a);
Console.WriteLine(b);
but there is a problem, for example i tried to split 12,6 but it splits the number 12 and 0,60000004
how can i fix this problem?
thanks
Loading

Aleksandar IlioskiRank #9,295 · 208 reputationPosted Mar 22, 2009, 4:51 PM EDT
float number = 12.3;
int iNum = Convert.ToInt32(number);
Console.Write(iNum);
Output: 12
nail8 reputationPosted Mar 22, 2009, 5:44 PM EDT
Aleksandar IlioskiRank #9,295 · 208 reputationPosted Mar 22, 2009, 6:49 PM EDT
double
fBroj;fBroj = 12.356 - 12;
Console.Write(fBroj.ToString("#.##")); // output : ,36;double
fBroj;fBroj = 12.353 - 12;
Console.Write(fBroj.ToString("#.##"));// output: ,35hope this is what you are looking, I thought you want to convert double or float to int not to take the decimal...
aru2 reputationPosted Mar 23, 2009, 1:13 AM EDT
int a = (int)number;
float
b = (float)Decimal.Subtract((Decimal)number, (Decimal)a); Console.WriteLine(a);Console.WriteLine(b);
Hope this is what you are looking for.
nail8 reputationPosted Mar 23, 2009, 2:47 PM EDT
Thak you so much