Login
Forum Help



Post Your Message
="hidden" name="cat" value="Programming">
Username: (Login)

Topic:
Message:
 


Previous Messages
Posted By

Austin
on 2005-01-07
15:33:12
 Re: Math error?

Can I just say how clever I think you all are ! Happy new year...

A.

Posted By

Litwr
on 2004-12-29
06:01:46
 Re: Math error?

1. n^m = e^(m*ln(n))
2. e^x = 1 + x + x^2/2 + x^3/6 + x^4/4! + ...
3. e = 2.718...
4. This floating point operations and number e are infinite so we and computers must stay after several steps and lose accuracy.

Posted By

SVS
on 2004-12-28
03:39:21
 Re: Math error?

The bug applies to numbers greater than integer range (32767) too. 10^7, 10^8 give the same wrong results. Only 10^2 and 10^1 happy are correct but probably because they are too small then the rounding is insignificant.

Posted By

Ulysses777
on 2004-12-27
13:10:45
 Re: Math error?

Try this...

10 A=10^3
20 B=1000
30 IF A=B THEN PRINT"Y":ELSE PRINT"X"

It should print Y, but it prints X. However, if you change A to A%, it works. happy

Posted By

JamesC
on 2004-12-27
13:08:50
 Re: Math error?

By using A% (integer variable), the answer is correct. If you are sure that the result will always be in the range covered by % variables, -/+ 32767 I believe, then this should be safe.

Posted By

SVS
on 2004-12-27
10:37:30
 Re: Math error?

@Csabo
... not exactly. If you store 10.000.000 the result is OK,
on the contrary if you store 10^7 result is wrong.
The bug seems to be on powering not on floating point operations.

Posted By

Csabo
on 2004-12-27
08:51:37
 Re: Math error?

Nice find. The problem seems to be in the "power of" function. You can force the poor old Plus/4 to admit it even without a division, just write:

? 100 = 10^2

(Where ^ is SHIFT+zero of course). This will evaluate to false. So one wonders what the differnce between 100 and 100 is, so let's see:

? 10^2 - 100

The answer of course is 2.98023224E-08 happy I guess the real problem lies in the fact that 100 is stored internally as an integer number, but 10^2 is not.

Posted By

MIK
on 2004-12-27
04:58:58
 Re: Math error?

Only a Professor could work this out Mr SVS. happy

To be honest I wouldn't have a clue. 1+1=3? wink

Posted By

SVS
on 2004-12-27
04:01:36
 Math error?

Type:
10 a=10^3
20 b%=1000/a
30 print b%

result is 0 instead of 1

happy


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon