Revision: 16372
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 2, 2009 05:53 by Zufolek
Initial Code
'returns a random integer less than A and greater than or equal to 0 DEF FNRN(A)=INT(RND(1)*A) 'rolls a die (singular of dice) DEF FNDI=FNRN(6)+1 'returns true at the specified probability, otherwise false 'FNPR(.7) is true 70% of the time DEF FNPR(P)=P>RND(1) 'flips a coin DEF FNFC=FNPR(.5) 'Like mod but works correctly for negative values of A 'Useful for Pac-Man-style screen wrapping and many other things DEF FNWR(A,B)=A-INT(A/B)*B 'hypotenuse DEF FNHY(A,B)=SQR(A*A+B*B) 'distance between 2 points in 2 dimensions DEF FND2(X1,Y1,X2,Y2)=SQR((X1-X2)^2+(Y1-Y2)^2) 'distance between 2 points in 3 dimensions DEF FND3(X1,Y1,Z1,X2,Y2,Z2)=SQR((X1-X2)^2+(Y1-Y2)^2+(Z1-Z2)^2) 'volume of a sphere DEF FNSV(R)=4.1888*R^3 'surface area of a sphere DEF FNSA(R)=12.5664*R^2
Initial URL
Initial Description
Initial Title
Some handy GW-BASIC or QBASIC functions
Initial Tags
Initial Language
Other