Reputation: 177
i get 4 byte data in network as float point number and when i convert it to a float number, result is like this: "7.346952E-40", but i want to show this number to user. when i round this number with Math.Round() function, result is "0.000". how can i round this float number to a simple float number like this: 123.456?
Upvotes: 0
Views: 139
Reputation: 127563
The number 7.346952E-40 is actually 0.0000000000000000000000000000000000000007346952, so when you round it to 4 decimal places you get 0.0000.
Upvotes: 3
Reputation: 9680
7.346952E-40 (7.346952 x 10^-40) is actually really close of 0, your rounding function is correct.
You can also use number.ToString("0.000") or number.ToString("#.###") to display your number depending of if you want only significant digits or a constant length number, like for currencies.
Upvotes: 0