-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
The result of LOG(2) in BASIC is a little bit off. It's debatable whether this is significant, since floating point numbers are generally imprecise. The result looks right when printed, but as seen in memory it's a little bit different from what the Commodore 64 calculates and from what it should be.
On both, "PRINT LOG(2)" shows .693147181. There are a few ways to see it's different:
- "PRINT 1000*(.7-LOG(2))" gives different results: 6.85281919 on X16, 6.85281931 on C64, and 6.85281928 on C128. An "ideal" result would be 6.85281944. C64's result is as close as it can be. X16's is more off.
- "PRINT 2↑15" gives 32768.0001 on X16 but not on C64. (This doesn't mean much. )
- Using the attached program (
fp-show.bas.txt) to show how LOG(2) is represented in memory. On X16 the mantissa is "B1 72 17 F9" while on C64 the mantissa is "B1 72 17 F8". The natural log of 2, in hex, is ".B17217F7D1CF79..." so the C64's value is closer. (The attached program has a bug in displaying the sign, but that's not important here.)
Seen with current ROM code (5d8ba9f) and also on rather older ROM (b6a0f0c). Seen with LOG(2) and LOG(2+2↑-30) and nothing else I've tried, including LOG(2.000001).
Metadata
Metadata
Assignees
Labels
No labels