MartyConnelly
martyconnelly at shaw.ca
Mon Oct 31 12:56:34 CST 2005
Disasters have been caused by computer arithmetic conversion errors, such as the famous unmanned Ariane 5 Rocket explosion in 1996. A 64-bit floating-point number in the inertial reference system was incorrectly converted to a 16-bit signed integer...BOOM Gustav Brock wrote: >Hi Marty > >You may have a point. I didn't give it a thought. >One could imagine that it does a type cast to double as a result of the division, then another back to long (or to double for the 100) for the comparison. > >Please note, this code doesn't serve any serious purpose except "doing something" that takes a little while. > >/gustav > > > >>>>martyconnelly at shaw.ca 31-10-2005 17:39:20 >>> >>>> >>>> >Just one hint for VBA code speed on this line >Since everything is being done by integers > > If alngTmp(lngItem, 1) / 10 = 100 Then > >On a run of 50 seconds >If I use integer division with the "\" operator , I save around 1 second > > If alngTmp(lngItem, 1) \ 10 = 100 Then > >If I use multiplication instead of division , I save 5-6 seconds >It does a type conversion to a long, but I have never seen a full >documented description of this >from MS so I don't trust it, so I would use CLng which would add overhead. > > If alngTmp(lngItem, 1) * 0.1 = 100 Then > >Some optimizing compilers have options that might change division by a >constant to multiplication of it's inverse. > > > > -- Marty Connelly Victoria, B.C. Canada