Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Arithmetic shifts

From: carl:cybercraft at: 17-Aug-2004 19:54

>Note that to-integer (or to integer!) isn't always required to return an >integer with division... > >>> type? 3 / 2 >== decimal! >>> type? 4 / 2 >== integer! >>> type? 12 / 4 >== integer! > >Which also allows us to do the likes of this... > >>> x: 5 and 254 / 2 >== 2 >>> type? x >== integer! > >I suspect this has speed advantages too, though I've not done any tests.
Have now and indeed it does...
>> t: now/time/precise loop 1000000 [2 / 2]print now/time/precise - t
0:00:00.93
>> t: now/time/precise loop 1000000 [2 / 2]print now/time/precise - t
0:00:00.94
>> t: now/time/precise loop 1000000 [2 / 2]print now/time/precise - t
0:00:00.94
>> t: now/time/precise loop 1000000 [3 / 2]print now/time/precise - t
0:00:01.43
>> t: now/time/precise loop 1000000 [3 / 2]print now/time/precise - t
0:00:01.43
>> t: now/time/precise loop 1000000 [3 / 2]print now/time/precise - t
0:00:01.37 And using AND's quicker than TO INTEGER! too...
>> t: now/time/precise loop 1000000 [3 and 254 / 2]print now/time/precise - t
0:00:01.59
>> t: now/time/precise loop 1000000 [3 and 254 / 2]print now/time/precise - t
0:00:01.59
>> t: now/time/precise loop 1000000 [3 and 254 / 2]print now/time/precise - t
0:00:01.54
>> t: now/time/precise loop 1000000 [to integer! 3 / 2]print now/time/precise - t
0:00:02.85
>> t: now/time/precise loop 1000000 [to integer! 3 / 2]print now/time/precise - t
0:00:02.86
>> t: now/time/precise loop 1000000 [to integer! 3 / 2]print now/time/precise - t
0:00:02.8 -- Carl Read