# Add to the last digit a number

I have data from a Multimeter that has a precision of 0.6%rdg+4dgt. So i want to take the last digit of, say, 12.007 and add 4 to the last digit like 12.011. I'm doing RealDigits[12.007,10,5][[1,-1]]add 4 and then somehow withFromDigits get the result...it seems trivial but i don't see how.

Perhaps something like:

ClearAll[func];
func[add_, pos_: (-1)] :=  N@FromDigits@MapAt[# + add &, RealDigits[##], {{1, pos}}] &

func[4, -1][12.007, 10, 5]
(* 12.011 *)
func[4, -3][12.707, 10, 5]
(* 13.107 *)

• it works fine but i want to use it in a rule like {a_,b_}->{a,fun[4,-1]@b}but it seems that first apply the function to a and then the substitution rule. Sep 1, 2014 at 14:11
• @Kafkarudo, can you give an example for the list you are trying to transform? Btw, perhaps you need :> instead of ->?
– kglr
Sep 1, 2014 at 14:23
• yep, the :> did it! thank a lot. Sep 1, 2014 at 14:28