VDouble.GetString return formatted string 15 char long

Ivan Smahin ivan_smahin at paradigmasoft.com
Tue Jun 14 03:37:04 CDT 2011


On 6/14/2011 9:56 AM, Bart Pietercil wrote:
> Hi,
>
> that would be precision and scale
>
> approximate_numeric_type
>      :    FLOAT  [ ( precision [, scale ] ) ]
>      |    DOUBLE [ ( precision [, scale ] ) ]
>
> However no more explanation is to be found . An explanation (maybe with an example) would come in handy.
>
> tia,
>
>
> Bart Pietercil
> CTO Cognosis NV
>
> On 14 Jun 2011, at 07:59, Ruslan Zasukhin wrote:
>
>> On 6/12/11 2:03 PM, "Bart Pietercil"<bart.pietercil at cognosis.be>  wrote:
>>
>>> No, we've been bitten also (in vReports, doubles show up the same way,
>>> annoying).
>>>
>>> Bart Pietercil
>>> CTO Cognosis NV
>>>
>>> On 11 Jun 2011, at 11:25, Francois Van Lerberghe wrote:
>>>
>>>> Hello,
>>>>
>>>> Using V4RB 4.3 mac_ub, if you store 12.345 in a VDouble,
>>>> VDouble.GetString return "      12.345000" (15 char long).
>>>>
>>>> In the previous versions (v1, v2, v3.5), VDouble.GetString gave me "12.345".
>>>>
>>>> This change broke a lot of my existing code.
>>>> Am I the only one who is affected by this change ?
>>>> Is it a bug or is it intentional ?
>>>> Can I modify this ?
>> DOUBLE and FLOAT fields
>>
>> More than year or two have additional properties
>>
>>     scale and ...
>>
>> I believe they control how value is converted into string.

Exactly. Precision and scale are for formatting double/float values 
getting them as a string values.
Default values are following:

For float - precision 6, scale 5
For double - precision 15, scale 6

You can manually set different settings:

create table t1 ( f1 double (10,2) )

insert into t1 values ( 1.0 )
insert into t1 values ( 1.1 )
insert into t1 values ( 1.123 )
insert into t1 values ( 12345678901.123 )

select f1 from t1
--
"      1.00"
"      1.10"
"      1.12"
"12345678901.12"


In other words - precision is a minimal length for value (including 
decimal point)
scale is a count of symbols after decimal point.

It is for "light" formatting of approximate values in a string 
representation.

Pay attention to the fact that both precision and scale don't affect the 
value - they are only about
formatting it.

For example -  you may apply "format" sql-function to get different results:

SELECT  FORMAT(123456.123456,  '###.##');

1
1.1
1.123
12345678901.123

Again - it is only about string output.

-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macserve.net/pipermail/valentina/attachments/20110614/e9f8500b/attachment.html>


More information about the Valentina mailing list