New topic: 

Double datatype in Variant gives erroneous math errors???

<http://forums.realsoftware.com/viewtopic.php?t=34297>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        hholzgrafe          Post subject: Double datatype in Variant 
gives erroneous math errors???Posted: Wed Jun 16, 2010 12:43 pm                 
        
Joined: Sun Dec 30, 2007 2:09 pm
Posts: 74                I have a project with just these two lines in it:

Dim y As Variant = 24.95
msgbox Str(y.DoubleValue) + " " + Str(y) + " " + Str(y.DoubleValue * 2) + " " + 
Str(y * 2)

The msgbox says: 24.95 2.4949999999999999e+1 49.9 48
y.doublevalue produces 24.95 as expected
y produces 24.95 in scientific notation (not as good, but reasonable)
y.doublevalue * 2 is 49.9 as expected

But here is the problem:
y * 2 = 48 !!!!!!!!!  What happened here?  Is this a bug or something 
fundamental that I don't understand about variants and doubles?
It appears that only the whole part of y was used in the calculation, but why?  
Isn't the variant type supposed to know there's a double in there and pass the 
entire number to the arithmetic calculation?  Why doesn't it?

-Helen   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to