home *** CD-ROM | disk | FTP | other *** search
- CONST DegToRad! = .0174533
- CONST RadToDeg! = 57.2958
-
- DEFINT A-Z
-
- DIM SINtab#(359)
- DIM COStab#(359)
-
- CLS
- PRINT "Please wait"
-
- FOR i = 0 TO 359
- x# = i * DegToRad!
- SINtab#(i) = SIN(x#)
- COStab#(i) = COS(x#)
- NEXT
-
- ' look up for ten seconds
-
- a! = TIMER
- i = 0
- j# = 0
- DO WHILE a! <> TIMER: LOOP
- DO WHILE TIMER - a! < 10
- x# = SINtab#(i)
- x# = COStab#(i)
- i = (i + 1) MOD 360
- j# = j# + 1
- LOOP
-
- ' calculate for ten seconds
-
- a! = TIMER
- i = 0
- k# = 0
- DO WHILE a! <> TIMER: LOOP
- DO WHILE TIMER - a! < 10
- x# = SIN(CDBL(i * DegToRad!))
- x# = COS(CDBL(i * DegToRad!))
- i = (i + 1) MOD 360
- k# = k# + 1
- LOOP
-
- CLS
- PRINT "lookup ="; j#
- PRINT "calculate ="; k#
- PRINT
- IF j# > k# THEN
- PRINT "It is faster to look up trig functions than to calculate them"
- PRINT "ratio:"; j# / k#; "lookups to each calculation"
- ELSE
- PRINT "It is faster to calculate trig functions than to look them up"
- PRINT "ratio:"; k# / j#; "calculations to each lookup"
- END IF
- SYSTEM
-
-
-
-
-
-