Board: Teensy 4.1
Environment: Platformio
Framework: Arduino-Teensy
platformio.ini:
NOTE: the code uses a modified arduino framework core to work with the ported FreeRTOS (https://github.com/tsandmann/platform-teensy.git#b92da4fa983a06230c46815f89b6ad788cdde023). This has an updated the G++ compiler.
Problem:
The teensy board seems to have trouble with math operations on double precision floating point variables. The value that is returned is different starting at around 7th significant digit, which makes me wonder if only 32-bit floating point operation is happening.
The result of the code below is compared to the output of computations in Wolfram Alpha.
The output of the code above produces the value of 0.639424294929401.
However, if you compare it to the Wolfram Alpha output for the same computation, you see the following:
0.63942427418458347537687
Once again, here is a comparison:
0.639424294929401
0.63942427418458347537687
As you can tell, the difference begins at the 8th significant digit. However, in some cases the difference begins at 7th digit, but never less.
Does anyone have an idea as to what may be happening?
Environment: Platformio
Framework: Arduino-Teensy
platformio.ini:
Code:
[teensy41]
platform = https://github.com/tsandmann/platform-teensy.git#b92da4fa983a06230c46815f89b6ad788cdde023
board = teensy41
framework = arduino
lib_deps =
https://github.com/tsandmann/freertos-teensy#379d9b5ad82f8c1be995f95add3fd32bb3add2c1
ssilverman/QNEthernet@^0.19.0
https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library.git#3416a3140fb74c3b80fc680140d029182fcd03ad
https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library.git
build_flags =
-DUSING_ARDUINO_DRIVERS
-DARDUINO_TEENSY41
NOTE: the code uses a modified arduino framework core to work with the ported FreeRTOS (https://github.com/tsandmann/platform-teensy.git#b92da4fa983a06230c46815f89b6ad788cdde023). This has an updated the G++ compiler.
Problem:
The teensy board seems to have trouble with math operations on double precision floating point variables. The value that is returned is different starting at around 7th significant digit, which makes me wonder if only 32-bit floating point operation is happening.
The result of the code below is compared to the output of computations in Wolfram Alpha.
Code:
#inclde "Arduino.h"
#include <math.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
double operand = 0.693749222;
double result = sin(operand);
Serial.println(result, 15);
delay(1000);
}
The output of the code above produces the value of 0.639424294929401.
However, if you compare it to the Wolfram Alpha output for the same computation, you see the following:
0.63942427418458347537687
Once again, here is a comparison:
0.639424294929401
0.63942427418458347537687
As you can tell, the difference begins at the 8th significant digit. However, in some cases the difference begins at 7th digit, but never less.
Does anyone have an idea as to what may be happening?