Newlib rounding bug with function lroundf()
Posted: Fri Jun 16, 2017 3:36 pm
The Newlib lroundf() function rounds all numbers between 1.0 and -1.0 to 0. Only numbers with an absolute value less than 0.5 should be rounded to 0. clib2 rounds numbers between 1.0 and -1.0 correctly.
Here is a small program that demonstrates the error when compiled and executed:
The output when the above program (named 'test') is compiled with newlib & executed:
6.Ram_Disk:> test
x = 0.900000 & a = 0
y = -0.900000 & b =0
The output when the above program (named 'test') is compiled with clib2 & executed:
6.Ram_Disk:> test
x = 0.900000 & a = 1
y = -0.900000 & b = -1
Can someone compile & test the above program, confirm the erronious result and file a bug report to get this fixed.
Here is a small program that demonstrates the error when compiled and executed:
Code: Select all
#include <proto/exec.h>
#include <proto/dos.h>
#include <math.h>
#include <stdio.h>
int main()
{
float x = 0.9;
float y = -0.9;
int a = 0;
int b = 0;
a = lroundf(x);
b = lroundf(y);
printf("x = %f & a = %d\n", x, a);
printf("y = %f & b = %d\n", y, b);
return 0;
}
6.Ram_Disk:> test
x = 0.900000 & a = 0
y = -0.900000 & b =0
The output when the above program (named 'test') is compiled with clib2 & executed:
6.Ram_Disk:> test
x = 0.900000 & a = 1
y = -0.900000 & b = -1
Can someone compile & test the above program, confirm the erronious result and file a bug report to get this fixed.