Pseudo-random numbers/PCG32: Difference between revisions

m
→‎{{header|REXX}}: corrected dshift, added ishift
(add REXX (for the "fun" of it)
m (→‎{{header|REXX}}: corrected dshift, added ishift)
Line 1,314:
DON'T use Rexx, however, for this type of problem unless you take the time spent
for some Java coffies!
<lang rexx>Numeric Digits 40
Numeric Digits 40
Call time 'R'
N = 6364136223846793005
state = x2d('853c49e6748fea9b',16)
Line 1,336 ⟶ 1,334:
Say format(z,2) ':' format(cnt.z,5)
End
Say time('E')
Exit
 
Line 1,372 ⟶ 1,369:
oldx2=b2x(oldb2)
rotx=x2d(substr(oldx2,9),8)
t1=dshiftishift(shifted,rotx,'L')
t2=x2d(xneg(d2x(rotx,8)),8)
t3=t2+1
Line 1,509 ⟶ 1,506:
Else Do
If o='L' Then Do
If left(nb,1)=1 Then
nb=copies(0,32)substr(nb,33)
rb=left(copies('0',s)nb,length(nb))
rx=b2x(rb)
ry=left(rx,8)
r=x2d(rx,16)
End
Line 1,520 ⟶ 1,514:
rx=b2x(rb)
r=x2d(rx,16)
End
End
Return r
 
ishift: Procedure
/**********************************************************************
* Implement the shift operations for an int variable
* r = dshift(int,shift[,mode]) >> Mode='L' logical right shift
* >>> Mode='A' arithmetic right shift
* << xhift<0 left shift
********************************************`*************************/
Parse Upper Arg n,s,o
Numeric Digits 40
If o='' Then o='L'
nx=d2x(n,8)
nb=x2b(nx)
If s<0 Then Do
s=abs(s)
rb=substr(nb,s+1)||copies('0',s)
rx=b2x(rb)
r=x2d(rx,8)
End
Else Do
If o='L' Then Do
rb=left(copies('0',s)nb,length(nb))
rx=b2x(rb)
ryr=leftx2d(rx,8)
End
Else Do
rb=left(copies(left(nb,1),s)nb,length(nb))
rx=b2x(rb)
r=x2d(rx,8)
End
End
2,300

edits