Post Reply 
N-Queens on 50g (RPL language)
11-21-2014, 04:27 PM
Post: #18
RE: N-Queens on 50g (RPL language)
Easy solution: replace n=10*k and work with the integers divided by 10, then compensate with the numeric factor, and no more integers anywhere:

Code:

<< 0. 1000. 0.1 FOR n
   0.02 n DUP 0.1 + * / +
   -0.1 STEP
>>

The exact result is:
1 followed by 'x' 9's, then an 8, followed by 'x' 0's, then repeats the sequence with a 1 followed by...
'x' is the exponent of the end of the loop. If the loop starts from 1e3, there's 3 9's and 3 zeroes:
1.999 8 000 1 999 8 000 1 999 8 000 1 999 8 000 ...

So it's easy to check for rounding errors even at higher precisions (which I want to benchmark too).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: N-Queens on 50g (RPL language) - Han - 11-06-2014, 03:29 AM
RE: N-Queens on 50g (RPL language) - Bruno - 09-08-2015, 10:41 AM
RE: N-Queens on 50g (RPL language) - Han - 11-20-2014, 08:53 AM
RE: N-Queens on 50g (RPL language) - Claudio L. - 11-21-2014 04:27 PM



User(s) browsing this thread: 1 Guest(s)