5
Answers

convert float to int

nail

nail

15y
27.2k
1
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)