Rnd

From Maze

(Difference between revisions)
Jump to: navigation, search
Line 4:Line 4:
−
=The random function (RND) as used in the commodore 64 program 10 print chr$(79+int(rnd(0)*2));:goto 10=
+
=The random function (RND) as used in Commodore 64 BASIC=
 +
with particular regard to: 10 print chr$(79+int(rnd(0)*2));:goto 10=
C64-specific:
C64-specific:
Line 23:Line 24:
−
=C64 floating-point=
+
==C64 Floating-Point==
The native number format of Commodore BASIC, like that of its parent MS BASIC, was floating point. Most of the contemporary BASIC implementations used one byte for the characteristic (exponent) and three bytes for the mantissa. This led to problems in business applications since the accuracy of a floating point number using a three-byte mantissa is only about 6.5 decimal digits, and round-off error is common. '''Commodore, however, used MS BASIC's four-byte mantissa, which made their BASIC much more adapted for business than most other BASICs of the era'''. (reference: http://en.wikipedia.org/wiki/Commodore_BASIC)
The native number format of Commodore BASIC, like that of its parent MS BASIC, was floating point. Most of the contemporary BASIC implementations used one byte for the characteristic (exponent) and three bytes for the mantissa. This led to problems in business applications since the accuracy of a floating point number using a three-byte mantissa is only about 6.5 decimal digits, and round-off error is common. '''Commodore, however, used MS BASIC's four-byte mantissa, which made their BASIC much more adapted for business than most other BASICs of the era'''. (reference: http://en.wikipedia.org/wiki/Commodore_BASIC)
Line 30:Line 31:
=Dartmouth BASIC=
=Dartmouth BASIC=
−
[http://dtss.dartmouth.edu/scans/BASIC/ Dartmouth BASIC code]
+
[http://dtss.dartmouth.edu/scans/BASIC/ Dartmouth BASIC source code in assembly]
−
This shows that the Dartmouth Basic (the first BASIC), had a similar specification for the RND(x) function. It generated a single stream of pseudorandom numbers. Interestingly, it recommends throwing away the first "115" or so numbers.
+
[http://www.bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf Dartmouth BASIC manual/specification]
 +
 +
The original BASIC manual shows that Dartmouth Basic (the first BASIC), had a similar specification for the RND(x) function. It generated a single stream of pseudorandom numbers. Interestingly, it recommends throwing away the first "115" or so numbers. (reference: BASIC_Oct64.pdf, page 45 of PDF, page -39- of original document)
−
Survey of Random Number algorithms
+
=Survey of Random Number Algorithms=

Revision as of 15:52, 10 May 2010

View this revision of Rnd.

Personal tools