View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
okaizawa okaizawa is offline
external usenet poster
 
Posts: 129
Default Inputbox error? 10 divided by 100 equals 0.100000001490116 ???

Hi,
0.1 of Double and 0.1 of Single are not same and not just 0.1.
See
http://support.microsoft.com/default...kb;en-us;78113
Floating-point arithmetic may give inaccurate results in Excel
(BTW, "0001100110011100110011 (and so on)" is wrong.)

You should use Double type for cell values, like:
Dim aa As Double

--
HTH
okaizawa

staying wrote:
Hey, guys.

I was setting up an inputbox for percentile value input, and the
weirdest thing happened. The code follows.

====================
Option Explicit

Sub inputboxtest()

Dim aa As Single

aa = Application.InputBox(Prompt:="Type in 10 for 10 percent", Type:=1)
/ 100
MsgBox aa
ActiveSheet.Range("a1").Value = aa

End Sub
====================