nail

nail

  • NA
  • 8
  • 0

convert float to int

Mar 22 2009 6:01 PM
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

Answers (5)