New topic: 

DoubleValue: DV <> Val(Str(DV)). Why?

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

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        mpastor          Post subject: DoubleValue: DV <> Val(Str(DV)). 
Why?Posted: Mon Nov 05, 2012 12:35 pm                         
Joined: Sat Oct 18, 2008 4:58 pm
Posts: 98                I feel like I am missing something basic here (no pun 
intended).
Converting a double to a string and back to a double doesn't work.
What am I supposed to know?

Evidence...
CODE
  // TIME VALUE TEST
  Dim d1 As New Date
  Dim d2 As New Date
  Dim d3 As New Date
  
  Dim ds2 As String
  
  d2.TotalSeconds = d1.TotalSeconds // d1 and d2 should be equal
  
  ds2 = str(d2.TotalSeconds) // total seconds as string - does something get 
truncated here?
  d3.TotalSeconds = val(ds2) // total seconds converted back to val from string 
(assuming val is Double)
  
  Dim dv1,dv2 As Double
  Dim dvs2 As String
  
  // NUMBER VALUE TEST
  dv1 = 0.123456789
  dvs2 = str(dv1)
  dv2 = val(dvs2)
  
  // OUTPUT RESULTS
  TextArea1.Text = _
  "TIME VALUE TEST"+EndOfLine+_
  "d1: "+d1.SQLDateTime+EndOfLine+_
  "d2: "+d2.SQLDateTime+EndOfLine+_
  "d3: "+d3.SQLDateTime+EndOfLine+EndOfLine+_
  "NUMBER VALUE TEST"+EndOfLine+_
  "dv1: "+str(dv1)+EndOfLine+_
  "dv2: "+str(dv2)
  

OUTPUT
TIME VALUE TEST
d1: 2012-11-05 10:34:11
d2: 2012-11-05 10:34:11
d3: 2012-11-05 10:26:40

NUMBER VALUE TEST
dv1: 0.1234568
dv2: 0.1234568   
                             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