So I was porting one of the old BASIC games from the book "BASIC Computer Games", Ref: https://github.com/coding-horror/basic-computer-games to Python, just for fun.
I came across the following expression in the "Fur Trader" game, which the book says works in Microsoft Basic circa 1978 (Ref: Page IX, "BASIC Computer Games"):
LET E1=INT((.15*RND(1)+.95)*10^2+.5)/10^2
It's been a "few" years since I did much BASIC. I am puzzled by the use of 10^2
.
Is there any particular reason why the author may have chosen this syntax? Why not just use the constant 100
. It seems a weird choice for a book targeted at beginners.
According to the (current) Basic manual, the operator precedence for ^
is the highest. Was this always the case?
This makes my python version look like:
int( ( 0.15 * random.random() + 0.95 ) * 100 + 0.5 ) / 100
Is it correct? My interest is getting same result as the original expression, not in preserving the actual expression.
10^2
instead of a saner100
is pretty much par for the course, and I wouldn't attribute any special meaning or intention to it.