Decimal separator

Hello all,

Lucee is using .(dot) as decimal separator for numbers. Is it possible to be set up as ,(comma)? Client reported bug that NumberFormat function can’t cast 500.00 as number.

Thanks

See, check documentation for LSNumberFormat() and SetLocal()

1 Like

Thank you, but I was asking can type number be written with comma as decimal separator, not print as such?

No, that is not possible and that’s not how it works. What @Roberto_Marzialetti told you is probably the best you’ll probably can do.

Each data-type needs a unique format to store its own data, and that can’t be changed. Any time you are seeing something different, than it is just formatting the same data.

What you are asking is basically like changing the way a dateobject is stored in a database. E g. in mySQL its stored as {ts ‘2022-11-11 13:12:01’ }. You can’t change it for the data type dateTime. The same way its with data type numeric in cfml.

But you can print any data in such a way you need.

nope, internally all languages I’m aware of stick to dots, otherwise it’s a world of pain, look at the pain due to Americans with their silly date format!

updateInvoice(userid=1, amount=3,2); // is going to a throw a mixed name and unnamed arguments exception

Thank you all.

The best is the issue with dates, where 12.1.2021 is the 12th January in Germany, but 12/1/2021 is the 1st of December in the US. Locale hell!!! Makes a devs life more work! :rofl:

@Aleksandar_Petrovic: Lucee is using .(dot) as decimal separator for numbers. Is it possible to be set up as ,(comma)? Client reported bug that NumberFormat function can’t cast 500.00 as number.

Others have answered that that is not possible. I only wish to add that you could, if necessary, write a function to do the conversion for you.

You could pass the amount, the mask and the locale as arguments. The function(s) could then convert from point to comma notation and vice versa. For example, using LSNumberFormat() and LSParseNumber().

<cfscript>
amount_1_InFrenchLocale=LSNumberFormat( number=500, mask="999.99", locale="fr_FR" );
amount_2_InFrenchLocale=LSNumberFormat( number=300, mask="999.99", locale="fr_FR" );

writeoutput("amount_1_InFrenchLocale: " & amount_1_InFrenchLocale & "<p>");

amount_1=LSParseNumber(amount_1_InFrenchLocale,"fr_FR");
amount_2=LSParseNumber(amount_2_InFrenchLocale,"fr_FR");

totalAmount=amount_1+amount_2;
writeoutput("totalAmount: " & totalAmount);
</cfscript>
1 Like