main logo
Subject: Re: [V4RB] VFloat - strange behavior
Author: john roberts
Posted: 2001/08/30 08:53:05
 
View Entire Thread
New Search


on 8/30/01 8:43 AM, Francois Van Lerberghe at fvanlerberghe (AT) freegates D.O.T be
wrote:

>>> With the value 12394.68, I get :
>>>
>>> FloatField.GetString -> 12394.7 (same in VApp)
>>> FloatField.Value -> 12394.6796875
>>>
>>> Using VDouble, I get the same value that I store.
>>
>> Maybe in the examples you looked at; however, there will be others where
>> this is not the case.
>>>
>>> 1/ Is there
>>> - a mathematical issue
>>> - a Valentina issue
>>> - a RealBasic issue
>>
>> Sort of all three. Basically the problem is representation of decimal
>> numbers within the computer. Certain fractional forms are not precisely
>> representable as a number.
>
> Ok, I agree with you.
> But don't you think that you should retrieve the same value using
> FloatField.GetString or FloatField.Value ?

Since you are working with RB and v4rb you can limit your attention to
integers and doubles. Floats are an alien thing in RB and will get converted
to doubles anyway. As I noted previously, storing the data as vDoubles will
still yield data in the db having more than 2 decimal digits when viewed
with VAPP (or whatever). The only way around this is to store them as
strings (which I like) or as integers (and then dividing by 100 when
needed).

In my own work I tend to use "getString" to bring the data back into RB and
the "cdbl" function to convert it to a numeric. The reason I do this is that
it allows me to store the data formatted for display.

Best regards,
John Roberts

mailto:jarobe01@athena.louisville.edu
 
©2001 john roberts
<-- Prior Message New Search Next Message -->