Comments (5)
This issue might be the similar to #1401 where the double is being cast to a float and that causes a loss of precision.
from home.
Duplicate with #1429
See that specific issue for the answer.
I will close this issue.
from home.
@Ellerbach I must disagree that this is not a bug.
While it is understood that floating-point arithmetic can introduce small errors due to the way numbers are represented in binary, the numbers 14 and 92 can be exactly represented in the IEEE 754 standard used for floating-point arithmetic. Therefore, when converted to a string, they should retain their exact integer representation without any introduced imprecision.
Even (as you wrote) less smart languages like Python can deal with the numbers 14 or 92 but nanoFramework not.
Another thing that makes something wrong is that this code
double d = 14d;
Console.WriteLine($"{d}");
will print 13.999999999999999
and the use of float, a less precise variable,
float f = 14f;
Console.WriteLine($"{f}");
already works properly
Additionally, I looked around the code and there is even a test that checks this https://github.com/nanoframework/CoreLibrary/blob/main/Tests/NFUnitTestArithmetic/UnitTestFormat.cs#L189 but the selected number in the test does not cause a problem. Replacing -1234 with -14 would cause this test to fail.
from home.
OK, reopening the issue. That say, it depends of the device precision. Double is always available, but if not natively supported, will automatically fall back to float.
from home.
Actually, that's the other way around: float is always available. Double is natively supported if the platform has DP hardware support (or emulated).
Rational for this is explained in our docs here
from home.
Related Issues (20)
- Modbus library will skip first byte received HOT 9
- Support ESP32_S3 Octal SPIRAM HOT 6
- ESP32 - nanoFramework.Json.DeserializationException HOT 12
- Serial port broken on XIAO ESP32C3 after upgrade from 1.9.1.7 HOT 2
- Error on ESP32S3 since nanoff updated to 2.5.66
- Problems with 96x16 OLED display
- Missing icons in Device Explorer HOT 1
- `DateTime.Parse` does not handle string that conform to RFC 3339 HOT 2
- I2cDevice is throwing an ArgumentException for busId=2 HOT 5
- Add generic display to target ESP32_S3_BLE HOT 10
- ESP32 S3 - Wifi AP not working anymore HOT 8
- Enable Bluetooth 5.0 Feature on ESP32 MCU
- ESP32_S3_ALL does not recognize PSRAM on ESP32-S3-Zero device HOT 3
- ESP_S3 could not boot on ESP32_S3_ZERO HOT 1
- WiFi AP crashes debugger HOT 3
- nanoFramework.System.Device.I2c and .Slave not working as expected when sending bytes from master to slave HOT 1
- nanobuild@v1 GitHub action fails due to 403 rate limit response
- Visual Studio 2022 Device Explorer does not find the device HOT 7
- `nanoCLR` throws a System.AccessViolationException on Windows Server 2022 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from home.