guru_trader 485 posts msg #105079  Ignore guru_trader 
2/21/2012 3:35:58 AM
For example: I want the hundredth digit of the close of SPY on 2/17/2012 = 136.41
This method worked as expected:
a) 136.41 * 100 = 13641.33 ... shift hundredth digit 2 places to left, revealing additional precision
b) mod(13641.33,1) = remainder of (13641.33/1) = 0.33 ... frac() and int() functions would also be useful for these
c) 13641.33  0.33 = 13641.00 ... clean up the right side
d) 13641.00 / 10 = 1364.10 ... shift digits 1 place to right
e) mod(1364.10,1) = remainder of (1364.10/1) = 0.10
f) 0.10 x 10 = 1.00 ... shift digit 1 place to left
*Here is another version that I thought would work, but for some reason this method did not produce the results I expected. In some cases it rounded the hundredth digit up and in other cases it rounded the hundredth digit down.
a) 136.41 * 10 = 1364.133
b) mod(1364.133,1) = remainder of (1364.133/1) = 0.133
c) 0.133 x 10 = 1.33
d) mod(1.33,1) = 0.33
e) 1.33  0.33 = 1.00
