Help! Math problem

I am using vb in excel and have run into an issue I can't figure out.

Just for testing, I have a form with a button that calls a function:
function test()
dim a
a = 1.09 - 1
msgbox a
end function

I am looking for the answer to be .09 but I get 9.00000000000001E-02
I have played with it a bit. If I make the equation a = 1.9 - 1 ,I get 0.9 and if I make it a = 1.099 - 1 , I get 0.099. Does anyone know what the cause of this is

Thanks in advance!!



Answer this question

Help! Math problem

  • Range_Finder

    Just the precision which Excel holds numbers to try formating the answer as below

    MsgBox (Format(a, "0.##"))


  • neetu_fzr

    ahh! thanks so much!
  • Help! Math problem