25 July 2018, 18:52 | #21 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Interesting.
Could you unload the good and bad libraries so we can compare, or at least verify version numbers? |
25 July 2018, 19:07 | #22 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Three libs are the same.
Only one is different The bad one is mathieeedoubbas.library mathieeedoubbas 37.1 (21.1.91) Good one mathieeedoubbas.library mathieeedoubbas 38.2 (24.1.92) Bad one size: 5244 bytes Good one size: 5240 bytes |
25 July 2018, 19:42 | #23 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
So, looking at the version numbers, we can jump wildly to the conclusion that this library was broken in 2.04 and fixed by the time 2.1 was released. The library was available with 1.3 (I haven't verified this, I'm just going by what I see online) but we don't know if that version was broken. We don't know whether the version shipped with 2.05 was broken or not.
Still, doesn't explain how the library can return the right result some of the time (it's only broken for that specific input and when called by itself, it works fine when called as part of the varargs of the last printf), which makes me very suspicious that something else is actually going on, bearing in mind how central and crucial this library would have been to many applications. Last edited by deimos; 25 July 2018 at 19:50. |
25 July 2018, 19:49 | #24 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Quote:
Not that much ! Floats are quite rarely used, at least for what typically runs on machines with v37. If it's a corner case (which i suspect) then the bug might have gone inconspicuous for a long time. |
||
25 July 2018, 19:52 | #25 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,187
|
Was the A3000 image using hardware FPU? That could affect things as well.
|
25 July 2018, 20:24 | #26 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
I get that bugs can appear to be random, but I don't agree that floats are rarely used, or that this is a corner case. You might argue that there weren't commercial applications using floats (I disagree), but don't forget the thousands of bedroom coders.
cos(M_PI / 2) The cosine of 90 degrees. And no one noticed, all the way through 2.04 and 2.05? No one got their hot new graphics computer and their brand new c compiler and tried to draw a circle? If this was 25 years ago I would dissassemble the different versions of the libraries to look for the difference, but frankly, today, I wouldn't know how. Quote:
|
|
25 July 2018, 20:24 | #27 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
25 July 2018, 20:37 | #28 | |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,377
|
Quote:
|
|
25 July 2018, 20:40 | #29 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
So, how can we explain this:
Code:
#include <math.h> #include <stdio.h> double xsin(double a) { double x = sin(a); // x += 0.000001; return x; } double xcos(double a) { double x = cos(a); // x += 0.000001; return x; } int main(int argc, char const *argv[]) { double a = M_PI / 2; double x = xcos(a); double y = xsin(a); printf("%f: %f, %f\n", a, x, y); return 0; } 1.570796: 0.000000, 0.000000 i.e. incorrect. Un-comment the two lines that are commented and run it again, I get: 1.570796: 0.000000, 1.000001 i.e. correct. |
25 July 2018, 20:45 | #30 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,377
|
Did you read my previous post already before creating your new test?
The xcos() result is also not correct in the second case. It still looks like a printf() problem with Fix() or maybe other string formating functions.. Last edited by PeterK; 25 July 2018 at 20:52. |
25 July 2018, 20:46 | #31 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
25 July 2018, 20:54 | #32 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
25 July 2018, 20:58 | #33 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,377
|
Should be 0.000001 or not?
|
25 July 2018, 20:58 | #34 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
25 July 2018, 21:00 | #35 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
We're not in the PC world (where floats are indeed scattered all over the place, especially at wrong places). Not exactly. There is no way to represent PI/2, it has to be an approximation. Who knows what lurks then. Right, no one noticed. Or someone did, and it got fixed in v38. Many games just don't use the OS. Same for demos. Very few utilities will use floats. Drawing some sine is best done with tables. So it's not surprising at all. Besides, we have 3 versions of math libraries (ffp, single, double). Quote:
Quote:
|
|||
25 July 2018, 21:01 | #36 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
|
25 July 2018, 21:01 | #37 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,377
|
I would expect 1.570796: 0.000001, 1.000001 or do I need a beer?
Ok, ok, a typo can happen. But I will get my beer anyway ... |
25 July 2018, 21:15 | #38 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,377
|
Okay, that's indeed possible. But I know these strange printf() outputs already from my mathlibs where they always happened when Fix() was done with the wrong rounding mode. Printf() seems to use Fix() to format the output string. But of course, other functions in mathieeedoubas.library may be involved, too. Sometimes I had exactly the same hex return values from some trigonometric or logarithmic functions and only the rounding mode of mathieeedoubbas.library was responsible for a different printf() output.
|
25 July 2018, 21:16 | #39 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
I just don't like not understanding. I won't feel comfortable coding in this environment until I do. |
|
25 July 2018, 21:27 | #40 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
I don't think we can blame printf, changing that line to:
printf("%f: %f, %f | %f\n", a, x, y, (x - y) * 123.0); gives: 1.570796: 0.000000, 0.000000 | 0.000000 suggesting that both x and y are really 0.0. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbcc 0.9f released | phx | News | 49 | 01 April 2018 11:33 |
vbcc V0.9e released | phx | News | 17 | 31 October 2016 21:18 |
VBCC and #include | majikeyric | Coders. C/C++ | 3 | 03 March 2016 15:07 |
vbcc 0.9d | phx | News | 43 | 13 July 2015 19:41 |
VBCC 0.8j for Windows | hitchhikr | Coders. General | 11 | 09 October 2008 00:58 |
|
|