NumberFormat() mask bug?

I would assume the code below should return 00, but Lucee 4.5 and 5 return
a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

Regards,
Adam

I would assume the code below should return 00, but Lucee 4.5 and 5 return
a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

TryCF.com

Yup: that’s a bug.On Monday, 13 July 2015 06:46:07 UTC+1, Adam Chapman wrote:

Regards,
Adam

isn’t the mask a string?

writeOutput(NumberFormat(0, '00')); On 13 July 2015 at 13:46, Adam Chapman <@Adam_Chapman> wrote:

I would assume the code below should return 00, but Lucee 4.5 and 5 return
a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

TryCF.com

Regards,
Adam


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

AJ Mercer
<webonix:net strength=“Industrial” /> http://webonix.net | <webonix:org
community=“Open” /> http://webonix.org
http://twitter.com/webonix

Thanks for the explanation…

wraps 00 in quotesOn Mon, 13 Jul 2015 17:02 Michael Offner <@Michael_Offner> wrote:

Nope, output is correct, the patten you pass (00) is a number not a string.
the numeric literal 00 is a valid numeric literal, but of course when the
parser converts that literal to a number you end with 0 there is no number
00.
you need to pass this as literal string to get the expected result:
writeOutput(NumberFormat(0, “00”));

You get the expected result in ACF, because in ACF all literals get
converted to strings by the parser, ACF converts all literals to Strings,
take this example:
writeOutput(serializeJson( 00)); // output:“00”

This outputs “00” (with " around the numbers), because already the parser
convert the literal to a string.

Or better take this example:

n=0;
b=true;
s=“”;

writeOutput(n.getClass().getName());
writeOutput(“
”);
writeOutput(b.getClass().getName());
writeOutput(“
”);
writeOutput(s.getClass().getName());
writeOutput(“
”);

this outputs in Lucee:
java.lang.Double
java.lang.Boolean
java.lang.String
and in ACF:
java.lang.String
java.lang.String
java.lang.String

Why ACF converts everything to a String is not clear to me, in Railo we
decided from version 1 not to follow ACF on this for a simple reason.
When someone defines a number, he will mostly likely use it as a number,
so we should keep it as a number.
In CFML it does mostly not matter what type it is (it does only in cases
like this), but because it is faster to convert a number to a string than a
string to a number, we decide to keep the type and not follow ACF on this.
When the json functions was introduced ACF had big problems, because they
got outputs like the one above (" around literal numbers). They then added
a patch for this that converts string that contains number to numbers, what
is not really a good solution then this conversion cannot no, if string is
by accident a string or not. take this example
writeOutput(serializeJson(0));
writeOutput(serializeJson(“0”));
In that case the ACF parser converts the first literal to a string and the
function serializeJson converts both inputs to numbers, so we get the
output
00
but it should be
0"0"

maybe ACF 12 will fix this, because they plan to clean up, we will see.

Micha

Micha

On Mon, Jul 13, 2015 at 7:46 AM, Adam Chapman <@Adam_Chapman> wrote:

I would assume the code below should return 00, but Lucee 4.5 and 5
return a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

TryCF.com

Regards,
Adam

You received this message because you are subscribed to the Google Groups

“Lucee” group.

To unsubscribe from this group and stop receiving emails from it, send an

email to lucee+unsubscribe@googlegroups.com.

To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to a topic in the
Google Groups “Lucee” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/lucee/j2UCyLmcPrU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Why ACF converts everything to a String is not clear to me, in Railo we
decided from version 1 not to follow ACF on this for a simple reason.
When someone defines a number, he will mostly likely use it as a number,
so we should keep it as a number.

We have the case that ACF would not throw an error when using Numberformat
with a negative number (where Lucee seems to insert a space between the
number and the minus sign)
which in turn throws an error when performing a calculation on it.

eg:

<cfset ax = NumberFormat(variables.tmp, ‘999,999.00’) />
<cfset Form.V1S1 = (ax - ListLast(Form.VUA1))*ListFirst(Form.VUA1) />

has anybody else had this issue?On Monday, July 13, 2015 at 4:22:07 AM UTC-5, Adam Chapman wrote:

Thanks for the explanation…

wraps 00 in quotes

On Mon, 13 Jul 2015 17:02 Michael Offner <mic...@lucee.org <javascript:>> wrote:

Nope, output is correct, the patten you pass (00) is a number not a
string.
the numeric literal 00 is a valid numeric literal, but of course when the
parser converts that literal to a number you end with 0 there is no number
00.
you need to pass this as literal string to get the expected result:
writeOutput(NumberFormat(0, “00”));

You get the expected result in ACF, because in ACF all literals get
converted to strings by the parser, ACF converts all literals to Strings,
take this example:
writeOutput(serializeJson( 00)); // output:“00”

This outputs “00” (with " around the numbers), because already the parser
convert the literal to a string.

Or better take this example:

n=0;
b=true;
s=“”;

writeOutput(n.getClass().getName());
writeOutput(“
”);
writeOutput(b.getClass().getName());
writeOutput(“
”);
writeOutput(s.getClass().getName());
writeOutput(“
”);

this outputs in Lucee:
java.lang.Double
java.lang.Boolean
java.lang.String
and in ACF:
java.lang.String
java.lang.String
java.lang.String

Why ACF converts everything to a String is not clear to me, in Railo we
decided from version 1 not to follow ACF on this for a simple reason.
When someone defines a number, he will mostly likely use it as a number,
so we should keep it as a number.
In CFML it does mostly not matter what type it is (it does only in cases
like this), but because it is faster to convert a number to a string than a
string to a number, we decide to keep the type and not follow ACF on this.
When the json functions was introduced ACF had big problems, because they
got outputs like the one above (" around literal numbers). They then added
a patch for this that converts string that contains number to numbers, what
is not really a good solution then this conversion cannot no, if string is
by accident a string or not. take this example
writeOutput(serializeJson(0));
writeOutput(serializeJson(“0”));
In that case the ACF parser converts the first literal to a string and
the function serializeJson converts both inputs to numbers, so we get the
output
00
but it should be
0"0"

maybe ACF 12 will fix this, because they plan to clean up, we will see.

Micha

Micha

On Mon, Jul 13, 2015 at 7:46 AM, Adam Chapman <adam.p....@gmail.com <javascript:>> wrote:

I would assume the code below should return 00, but Lucee 4.5 and 5
return a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

TryCF.com

Regards,
Adam

You received this message because you are subscribed to the Google Groups

“Lucee” group.

To unsubscribe from this group and stop receiving emails from it, send an

email to lucee+un...@googlegroups.com <javascript:>.

To post to this group, send email to lu...@googlegroups.com
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to a topic in the
Google Groups “Lucee” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/lucee/j2UCyLmcPrU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
lucee+un...@googlegroups.com <javascript:>.
To post to this group, send email to lu...@googlegroups.com <javascript:>
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

I wouldn’t depend on NumberFormat returning something that can be treated
as a numeric in CFML.

For instance, here in Switzerland, the thousands separator is an
apostrophe. A VAT calculation like

1’789.50 * 0.08

will also throw an error. Format the number only for display.

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamediaOn Wed, Apr 27, 2016 at 11:44 PM, Scott Conklin <@Scott_Conklin> wrote:

Why ACF converts everything to a String is not clear to me, in Railo we
decided from version 1 not to follow ACF on this for a simple reason.
When someone defines a number, he will mostly likely use it as a
number, so we should keep it as a number.

We have the case that ACF would not throw an error when using Numberformat
with a negative number (where Lucee seems to insert a space between the
number and the minus sign)
which in turn throws an error when performing a calculation on it.

eg:

<cfset ax = NumberFormat(variables.tmp, ‘999,999.00’) />
<cfset Form.V1S1 = (ax - ListLast(Form.VUA1))*ListFirst(Form.VUA1) />

has anybody else had this issue?

On Monday, July 13, 2015 at 4:22:07 AM UTC-5, Adam Chapman wrote:

Thanks for the explanation…

wraps 00 in quotes

On Mon, 13 Jul 2015 17:02 Michael Offner mic...@lucee.org wrote:

Nope, output is correct, the patten you pass (00) is a number not a
string.
the numeric literal 00 is a valid numeric literal, but of course when
the parser converts that literal to a number you end with 0 there is no
number 00.
you need to pass this as literal string to get the expected result:
writeOutput(NumberFormat(0, “00”));

You get the expected result in ACF, because in ACF all literals get
converted to strings by the parser, ACF converts all literals to Strings,
take this example:
writeOutput(serializeJson( 00)); // output:“00”

This outputs “00” (with " around the numbers), because already the
parser convert the literal to a string.

Or better take this example:

n=0;
b=true;
s=“”;

writeOutput(n.getClass().getName());
writeOutput(“
”);
writeOutput(b.getClass().getName());
writeOutput(“
”);
writeOutput(s.getClass().getName());
writeOutput(“
”);

this outputs in Lucee:
java.lang.Double
java.lang.Boolean
java.lang.String
and in ACF:
java.lang.String
java.lang.String
java.lang.String

Why ACF converts everything to a String is not clear to me, in Railo we
decided from version 1 not to follow ACF on this for a simple reason.
When someone defines a number, he will mostly likely use it as a number,
so we should keep it as a number.
In CFML it does mostly not matter what type it is (it does only in cases
like this), but because it is faster to convert a number to a string than a
string to a number, we decide to keep the type and not follow ACF on this.
When the json functions was introduced ACF had big problems, because
they got outputs like the one above (" around literal numbers). They then
added a patch for this that converts string that contains number to
numbers, what is not really a good solution then this conversion cannot no,
if string is by accident a string or not. take this example
writeOutput(serializeJson(0));
writeOutput(serializeJson(“0”));
In that case the ACF parser converts the first literal to a string and
the function serializeJson converts both inputs to numbers, so we get the
output
00
but it should be
0"0"

maybe ACF 12 will fix this, because they plan to clean up, we will see.

Micha

Micha

On Mon, Jul 13, 2015 at 7:46 AM, Adam Chapman adam.p....@gmail.com wrote:

I would assume the code below should return 00, but Lucee 4.5 and 5
return a single 0. Coldfusion returns 00.

writeOutput(NumberFormat(0, 00));

TryCF.com

Regards,
Adam

You received this message because you are subscribed to the Google

Groups “Lucee” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to lucee+un...@googlegroups.com.

To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com
https://groups.google.com/d/msgid/lucee/639499f2-383c-4d6f-ae51-fbe18c7196f3%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to a topic in the
Google Groups “Lucee” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/lucee/j2UCyLmcPrU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG%2BEEBwsXGvrQRQco38%2Bq5T7eoWuwQNfZRU%2BtWPxnV152OEtCQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/523b6cf9-3d3f-49e6-b71c-bf66d9bd97e9%40googlegroups.com
https://groups.google.com/d/msgid/lucee/523b6cf9-3d3f-49e6-b71c-bf66d9bd97e9%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.