-
-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Labels
Description
Library/API/IoT binding
nanoframework.System.Math
Visual Studio version
VS2022 17.3.6
.NET nanoFramework extension version
2022.2.0.44
Target name(s)
ESP32_REV3
Firmware version
1.8.0.699
Device capabilities
No response
Description
Rounding a double to two(2) decimal places does not work as expected. The results is the same as the source.
How to reproduce
double tempValue = 36.3999999d;
// This return 3640 which is correct
Console.WriteLine("Round: " + Math.Round(tempValue * 100d) );
double roundedValue = Math.Round(tempValue * 100d) / 100d;
// This return 36.3999999 which is wrong, Correct value is 36.4
Console.WriteLine("Rounded Value: " + roundedValue);
Console.WriteLine("Rounded Value to String : " + roundedValue.ToString());
Expected behaviour
There result should be 36.4. This result is confirmed correct on .Net 6.
Screenshots
No response
Sample project or code
No response
Aditional information
No response