Welcome to the .NET nanoFramework System.Math Class Library repository
Build status
Component | Build Status | NuGet Package |
---|---|---|
nanoFramework.System.Math |
Available APIs and floating-point implementations
The .NET System.Math APIs are available with double
parameters. No sweat for the CPUs where the code usually runs.
When we move to embedded systems that's a totally different story.
A few more details to properly set context:
double
type: represents a double-precision 64-bit number with values ranging from negative 1.79769313486232e308 to positive 1.79769313486232e308. Precision ~15-17 digits. Size 8 bytes.float
type: represents a single-precision 32-bit number with values ranging from negative 3.402823e38 to positive 3.402823e38. Precision ~6-9 digits. Size 4 bytes.- Comparison of floating-point numeric types.
There are all sorts of variants and combinations on how to deal with FP and DP in the embedded world. From hardware support on the CPU to libraries that perform those calculations at the expense of more code and execution speed. .NET nanoFramework targets 32-bit MCUs, therefore support for 64-bits calculations requires extra code and processing.
Adding to the above, the extra precision provided by the double
type is seldom required on typical embedded application use cases.
Considering all this and the ongoing quest to save flash space, despite System.Math API offering double
type parameters, the type handling at the native code will depend on build options of the firmware. The default implementation works with float
under the hood. There is a build option (DP_FLOATINGPOINT
) to build the image with DP floating point, which should be used when 'that' extra precision is required.
In case this is relevant, the capability of dealing with double floating point is exposed through this property SystemInfo.FloatingPointSupport
.
Feedback and documentation
For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.
Join our Discord community here.
Credits
The list of contributors to this project can be found at CONTRIBUTORS.
License
The nanoFramework Class Libraries are licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.