🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
2 messages
2 total messages Started by Thomas Kaulmann Sun, 22 Nov 1992 12:38
problems with g++-2.3.1, libg++-2.2, vax-ultrix
#361
Author: Thomas Kaulmann
Date: Sun, 22 Nov 1992 12:38
161 lines
7061 bytes
hello,

i've a problem in the libg++-2.2 test suite (rationals test) -
the problem occurs only on vax-ultrix. i've no probs with the stuff
on sunos, dec-ultix or ISC3.0..
the rest of the test works well, here are the results of the
tRational.cc test:

EXCEPT:
==========================================================================
one = 1
third = 1/3
half = 1/2
third + half = 5/6
third - half = -1/6
third * half = 1/6
third / half = 2/3
onePointTwo = 5404319552844595/4503599627370496
double(onePointTwo) = 1.2
a = 1
a += half = 3/2
a -= half = 1
a *= half = 1/2
a /= half = 1
approxpi = 355/113
double(approxpi) = 3.14159
rpi = Rational(PI) = 884279719003555/281474976710656
double(rpi) = 3.14159
approxpi + rpi = 199847224979684595/31806672368304128
approxpi - rpi = 8484881165/31806672368304128
approxpi * rpi = 313919300246262025/31806672368304128
approxpi / rpi = 19984723346456576/19984721649480343
-approxpi = -355/113
abs(negapproxpi) = 355/113

enter a Rational in form a/b or a: number = 61727839/49382716
approximating e as pow(1+1/n),n) for n =10
double(approxe) = 2.59374
log(approxe) = 0.953102
approxe = 25937424601/10000000000
approximating e as pow(1+1/n),n) for n =100
double(approxe) = 2.70481
log(approxe) = 0.995033
approxe = 2704813829421526093267194710807530833677938382781002776890201049117101
51430673927943945601434674459097335651375483564268312519281766832427980496322329
650055217977882315938008175933291885667484249510001/1000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000
approximating e as pow(1+1/n),n) for n =1000
double(approxe) = 2.71692
log(approxe) = 0.9995
approxe = 2716923932235892457383088121947577188964315018836572803722354774868894
94552376815899788569729866142905342103401540625692485946118761765388945775359308
33863995720635385004326501761444880461710448441218054796076480866070187420777983
75087855857012278053105042704758822511824867218226931719410407150364389665913091
82257681907228183573536578620217616722868619815846072464105240750630582621115696
47230644412959694982219192514792117009419351147555319726773601575614851442377868
16579422141378066423317811515462669946309306263409027388915931082226854264858661
42087827998353442412867246120635684746382136463050435966517157363539734603727475
24103681748774339412345431535111004716514728691160685284789769166005853834971801
72395573924789047989563714318957536493108041591460911612078698461739084741934442
44870141657548326389152909515801323311564853415408600931219048916854602439883424
38471351024116619960201295579214446663436410391379068075913427424642009919337227
91531063202677650581946360422!
027765645970182463780273161113009

End of test


OUTPUT:
==========================================================================
one = 1
third = 1/3
half = 1/2
third + half = 5/6
third - half = -1/6
third * half = 1/6
third / half = 2/3
onePointTwo = 21617278211378381/18014398509481984
double(onePointTwo) = 1.2
a = 1
a += half = 3/2
a -= half = 1
a *= half = 1/2
a /= half = 1
approxpi = 355/113
double(approxpi) = 3.14159
rpi = Rational(PI) = 28296951008113761/9007199254740992
double(rpi) = 3.14159
approxpi + rpi = 6395111199349907153/1017813515785732096
approxpi - rpi = 271516197167/1017813515785732096
approxpi * rpi = 10045417607880385155/1017813515785732096
approxpi / rpi = 3197555735433052160/3197555463916854993
-approxpi = -355/113
abs(negapproxpi) = 355/113

enter a Rational in form a/b or a: number = 61727839/49382716
approximating e as pow(1+1/n),n) for n =10
double(approxe) = 2.59374
log(approxe) = 0.953102
approxe = 25937424601/10000000000
approximating e as pow(1+1/n),n) for n =100
double(approxe) = 2.70481
log(approxe) = 0.995033
approxe = 2704813829421526093267194710807530833677938382781002776890201049117101
51430673927943945601434674459097335651375483564268312519281766832427980496322329
650055217977882315938008175933291885667484249510001/1000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000
approximating e as pow(1+1/n),n) for n =1000
double(approxe) = 2.71692
log(approxe) = 0.9995
approxe = 2716923932235892457383088121947577188964315018836572803722354774868894
94552376815899788569729866142905342103401540625692485946118761765388945775359308
33863995720635385004326501761444880461710448441218054796076480866070187420777983
75087855857012278053105042704758822511824867218226931719410407150364389665913091
82257681907228183573536578620217616722868619815846072464105240750630582621115696
47230644412959694982219192514792117009419351147555319726773601575614851442377868
16579422141378066423317811515462669946309306263409027388915931082226854264858661
42087827998353442412867246120635684746382136463050435966517157363539734603727475
24103681748774339412345431535111004716514728691160685284789769166005853834971801
72395573924789047989563714318957536493108041591460911612078698461739084741934442
44870141657548326389152909515801323311564853415408600931219048916854602439883424
38471351024116619960201295579214446663436410391379068075913427424642009919337227
91531063202677650581946360422!
027765645970182463780273161113009

End of test

DIFFERENCE
==========================================================================
8c8
< onePointTwo = 5404319552844595/4503599627370496
---
> onePointTwo = 21617278211378381/18014398509481984
17c17
< rpi = Rational(PI) = 884279719003555/281474976710656
---
> rpi = Rational(PI) = 28296951008113761/9007199254740992
19,22c19,22
< approxpi + rpi = 199847224979684595/31806672368304128
< approxpi - rpi = 8484881165/31806672368304128
< approxpi * rpi = 313919300246262025/31806672368304128
< approxpi / rpi = 19984723346456576/19984721649480343
---
> approxpi + rpi = 6395111199349907153/1017813515785732096
> approxpi - rpi = 271516197167/1017813515785732096
> approxpi * rpi = 10045417607880385155/1017813515785732096
> approxpi / rpi = 3197555735433052160/3197555463916854993


what is the error and how can i solve it??


thomax
-- 
Contributed Software, Thomas Kaulmann, Graefestr. 42, 1000 Berlin 61
G N U  &  N E T W O R K S  &  U N I X  Tel. : +49 30 694 69 07
Mail: thomax@contrib.de                Modem: +49 30 694 (6182|6749|6809)
Re: problems with g++-2.3.1, libg++-2.2, vax-ultrix
#362
Author: bothner
Date: Sun, 22 Nov 1992 15:52
34 lines
1614 bytes
> i've a problem in the libg++-2.2 test suite (rationals test) -
> the problem occurs only on vax-ultrix.

> what is the error and how can i solve it??

As far as I know, there is no error (except perhaps in the test itself).

The problem is that VAX floating-point uses a non-IEEE representation.
The problemantical tests involve converting (double) to Rationals.
The exact result will depend somewhat on floating-point representation.

Consider:
	8c8
	< onePointTwo = 5404319552844595/4503599627370496
	---
	> onePointTwo = 21617278211378381/18014398509481984

Using my 'Q' interpreter, I get:

	Q4> 5404319552844595/4503599627370496 * 1.0
	1.2
	Q5> 21617278211378381/18014398509481984 * 1.0
	1.2

So both results are actually correct.

Arguably, the tests should be re-written to be less sensitive
to floating-point representations.  I.e. one could take the
Rational, multiply by 1000, round to an integer, and then
divide by 1000, before printing the result.  I don't care
enough to do this myself, but I would consider patches to do so.

	--Per Bothner
Cygnus Support     bothner@cygnus.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads