Comments (5)
I cannot seem to reproduce this bug.
For me the result is 34481, which is 0.5 % error. This is within the expected
limits.
See attached test.c, I compiled it under x86_64 using GCC with this command:
gcc -o test test.c fix16.c fix16_trig.c fix16_sqrt.c
./test
sqrt: 113512 atan2: 34481
Original comment by Petteri.Aimonen
on 11 Apr 2013 at 3:07
Attachments:
from libfixmath.
The compiler i'm using is MSVC 2008 Express Edition version 9.0
Original comment by [email protected]
on 15 Apr 2013 at 11:03
from libfixmath.
Can you compile the test.c included earlier and tell us its output?
Original comment by Petteri.Aimonen
on 15 Apr 2013 at 12:55
from libfixmath.
sqrt: 113512 atan2: -2147432177
Original comment by [email protected]
on 15 Apr 2013 at 1:29
from libfixmath.
I'm also having difficulties with atan2. Here is the code I use to compare
atan2 for double and Fix16. I cannot expect Fix16 to be as accurate as double,
but there seems to be an offset of about 0.1 pi for some values. Here is the
code I use:
#include <cmath>
#include <fstream>
#include <iostream>
#include <fix16.h>
#include <fix16.hpp>
int main()
{
unsigned int n = 1000;
std::ofstream file("out.dat");
std::ostream& out(file);//(std::cout);
for(unsigned int i = 0; i <= n; i++)
{
double d = M_PI/2.*i/1000;
double s = sin(d);
double c = cos(d);
double a = atan2(s,c);
Fix16 df(d);
Fix16 sf(df.sin());
Fix16 cf(df.cos());
Fix16 af(sf.atan2(cf));
out << d
<< " " << a
<< " " << (double)af
<< std::endl;
}
return 0;
}
I used gnuplot for plotting the results, here is the command:
plot "out.dat" u 1:2 w l title 'double', "out.dat" u 1:3 w l title 'Fix16'
I have attached the plot.
Original comment by [email protected]
on 4 Feb 2014 at 9:10
Attachments:
from libfixmath.
Related Issues (20)
- div defect HOT 2
- Rounding broken for negative numbers HOT 5
- Problem with sdiv.. HOT 19
- C++ Fix16 cast operators should be const. HOT 1
- Optimize caching on trig functions
- Unittests fail on division, on x86_64 architecture. HOT 10
- Incorrect conversions from int to float and more HOT 4
- compiler error after setting #define FIXMATH_NO_OVERFLOW HOT 2
- left shift count >= width of type HOT 1
- >= 0 comparison might be more efficient than > 0 comparison HOT 1
- fix16_str_unittests fails (MSYS/windows) HOT 1
- FIXMATH_FAST_SIN gives rounding error HOT 1
- libfixmath for cortex m0 HOT 2
- fix16_div bug due to __builtin_clzl HOT 4
- Probably error in log2 functions test for skipping decimal part
- Unary minus on unsigned type HOT 1
- 32-bit multiplication seems to be way off for some values HOT 3
- Fix16(const fix16_t inValue) should be removed
- lerp overflows
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 libfixmath.