From: Todd Heiks on 7 Apr 2010 18:19 Why is 'ans1' true if double and false for single? Module Module1 Sub Main() Dim x As Double / Single Dim y As Double / Single Dim ans1 As Boolean Dim ans2 As Boolean x = 0.3000000000000001 y = Math.Round(x, 2) ans1 = y = 0.3 ans2 = Math.Round(y, 2) = 0.3 End Sub End Module Thanks
From: GS on 7 Apr 2010 18:42 Sub Main() Dim x As Double, y As Double Dim a As Single, b As Single Dim ansX As Boolean, ansY As Boolean Dim ansA As Boolean, ansB As Boolean x = 0.3: y = Math.Round(x, 2) a = 0.3: b = Math.Round(x, 2) ansX = (y = 0.3) ansY = (Math.Round(y, 2) = 0.3) ansA = (y = 0.3) ansB = (Math.Round(y, 2) = 0.3) End Sub This returns True for each Boolean (with OR without the math expressions being wrapped in parenthesis). -- Garry
From: MikeD on 7 Apr 2010 18:49 "Todd Heiks" <Todd.Heiks_AT_NoSpam_GreatLakesWindow.com> wrote in message news:OdvnfCq1KHA.752(a)TK2MSFTNGP04.phx.gbl... > Why is 'ans1' true if double and false for single? > > Module Module1 > Sub Main() > > Dim x As Double / Single > Dim y As Double / Single > > Dim ans1 As Boolean > Dim ans2 As Boolean > > x = 0.3000000000000001 > y = Math.Round(x, 2) > > ans1 = y = 0.3 > ans2 = Math.Round(y, 2) = 0.3 > > End Sub > End Module You need to ask this in one of the dotnet newsgroups. They all have "dotnet" or "vsnet" in their name. -- Mike
From: GS on 7 Apr 2010 18:54 x = 0.300000000000001: y = Math.Round(x, 2) a = 0.300000000000001: b = Math.Round(x, 2) This also returns True for all Booleans. **Note there is one less zero than your example because VB truncates what you posted to "0.3" as shown in my previous post. -- Garry
From: GS on 7 Apr 2010 18:58 on 4/7/2010, MikeD supposed : > > "Todd Heiks" <Todd.Heiks_AT_NoSpam_GreatLakesWindow.com> wrote in message > news:OdvnfCq1KHA.752(a)TK2MSFTNGP04.phx.gbl... >> Why is 'ans1' true if double and false for single? >> >> Module Module1 >> Sub Main() >> >> Dim x As Double / Single >> Dim y As Double / Single >> >> Dim ans1 As Boolean >> Dim ans2 As Boolean >> >> x = 0.3000000000000001 >> y = Math.Round(x, 2) >> >> ans1 = y = 0.3 >> ans2 = Math.Round(y, 2) = 0.3 >> >> End Sub >> End Module > > > You need to ask this in one of the dotnet newsgroups. They all have "dotnet" > or "vsnet" in their name. Well that explains why VB flagged the Dims in red! Do you mean that they can actually declare multiple types in a single statement? (Shows what I know about dotnet languages, huh!) -- Garry
|
Pages: 1 Prev: Referencing Flash OCX properly in vb6 Next: Why would the VB6 exe not show up in the task bar |