[Gambas-user] I create a new function to share

Doriano Blengino doriano.blengino at ...1909...
Fri Jun 26 23:18:28 CEST 2009


Benoît Minisini ha scritto:
>> Benoît Minisini ha scritto:
>>     
>>>> Changed file "/usr/share/i18n/locales/it_IT" so the section:
>>>>
>>>>     LC_NUMERIC
>>>>     decimal_point             "<U002C>"
>>>>     thousands_sep             ""      <------------ empty string
>>>>     grouping                  0;0
>>>>     END LC_NUMERIC
>>>>
>>>>
>>>> results in:
>>>>
>>>>     LC_NUMERIC
>>>>     decimal_point             "<U002C>"
>>>>     thousands_sep             "<U002E>"   <------- dot simbol
>>>>     grouping                  0;0
>>>>     END LC_NUMERIC
>>>>
>>>>
>>>> ...and now it works ok.
>>>>
>>>> I don't know why there is this error - don't even know if this *is* an
>>>> error, but now it works as expected. If somebody confirms to me that the
>>>> value of *thousand_sep* should not be empty, I can post a bug to the
>>>> maintainer of the file *BUT*:
>>>>
>>>> It is worth to note that in that file, a few lines above, in the section
>>>> LC_MONETARY, the thousand separator is correctly indicated. As Benoit
>>>> says, all this could be correct - if we want thousand separators perhaps
>>>> we have to use the monetary notation and not a "general number" one. In
>>>> fact, to separate the thousands is more a commercial habit than a
>>>> general/scientific one. But if this is true, then perhaps gambas lacks a
>>>> CURRENCY data type, or a mean to use a currency/monetary representation
>>>> inside format$(). By the way, a CURRENCY data type could come handy by
>>>> itself - I had some problems with rounding floating point values and, in
>>>> all the places where calculations were done (simple additions and
>>>> subtraction of numbers with only two decimals of precision, normal for
>>>> currency), I had to modify the code and round down values myself - tired
>>>> of "1.999,99999998" numbers...
>>>>
>>>> In other languages the CURRENCY datatype is defined as an INT64 which,
>>>> when printed or mixed with other numerical types, is first divided (or
>>>> multiplied) by 10000 (ten thousands). In other words, the number 22,5
>>>> (twentytwo and a half) is stored as the integer 225000. This way, all
>>>> rounding errors are get rid of.
>>>>
>>>> Regards,
>>>> Doriano
>>>>         
>>> I won't make a Currency data type, but you can do:
>>>
>>> Print Format$(Amount, "$0,###.##")
>>>
>>> to format currencies (see the documentation of Format).
>>>
>>> Regards,
>>>       
>> I saw the documentation, but not always I want to have the currency
>> symbol printed... is there a way to use the thousand separator without
>> putting a currency symbol in?
>>
>> Thanks anyway and regards,
>> Doriano
>>
>>     
>
> Don't put the '$' sign. But beware that then the thousand separator used won't 
> be the "currency" one but the normal one.
>
>   
...and this leads again to the starting point...

I don't know i18n enough, and perhaps Gambas neither, but this is what I 
have understood until now:

1. i18n says that a "normal" number has no thousand separator; instead a 
currency ("monetary") has it. Thinking again and again, this could make 
sense.

2. KDE desktop has its own management. Don't know how and why - perhaps 
those guys want to run KDE without i18n dependency. Gambas uses much of 
KDE, but not its locale settings. This again could make sense.

3. Using native Gambas functions there is no way to format a number like 
a monetary one, without putting the currency symbol in place.

4. Anyway, i18n says that the thousand separator is _nothing_, not a 
space. Which is different.

5. I *could* modify the relevant file, just to see it overwritten the 
next time a system update takes place. Anyway, I think that that file is 
correct.

All the things make sense, but I can not believe that one can not format 
a currency without putting the monetary symbol in. Sounds strange, true?

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list