Try the code:
float a = 0.77F;
int b = (int)(100 * a);
Console.WriteLine(b.ToString());
Result is 76.
What do you think about such strange .Net calculate execution ?
| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | VB Forums | Developer.com |
|
Results 1 to 7 of 7
Thread: Surprise! 0.77 * 100 == 76Threaded View
|
Click Here to Expand Forum to Full Width |