I work in a psych lab and am relatively new to R. I'm struggling to understand how trunc() works in the following example:
(1.125+.005)*100 # returns 113
trunc(113) # returns 113
trunc(113)/100 # returns 1.13
trunc((1.125+.005)*100)/100 # ...returns 1.12
On the final line, why does trunc() return 1.12 instead of 1.13? Very grateful for any help understanding this. Ultimately my goal is to 1) get a mean (here, 1.125) 2) add .005 (thus 1.13) 3) drop all digits after the second decimal place, without rounding (and get 1.13), hence trunc(x*100)/100.
Any help much appreciated!