bockensm
10/05/2022, 4:09 AMb = -a
makes sense to flip the sign on a variable regardless of whether a
is positive or negative. CF documents that both + and - perform unary arithmetic, so what should I be expecting from something like b = +a
given a
as a positive number or as a negative number?bockensm
10/05/2022, 4:10 AMx = +"7"
yields x
as a number type with a value of 7).seancorfield
b = -a
as equivalent to b = 0 - a
and b = +a
as equivalent to b = 0 + a
seancorfield
bockensm
10/05/2022, 4:16 AMa
= -10, b = +a
is the same as b = +-10
, which is -10seancorfield
0 + -10
is indeed -10
, yes.bockensm
10/05/2022, 4:17 AMseancorfield
bockensm
10/05/2022, 4:17 AMseancorfield
a
is -10
, then -a
is 10
.seancorfield
+
and unary -
.bockensm
10/05/2022, 4:19 AMseancorfield
seanc@Sean-win-11-laptop:~$ node
> a = -10;
-10
> -a;
10
> +a;
-10
>
seancorfield
+a
doesn't do "nothing". Try this:
a = "porcupine";
b = +a;
I think that will fail (it would fail in most languages)bockensm
10/05/2022, 4:21 AM+"10"
bockensm
10/05/2022, 4:21 AMbockensm
10/05/2022, 4:21 AMseancorfield
porcupine
for that but Lucee throws an exception that porcupine
is not numeric. So I think ACF is broken there.bockensm
10/05/2022, 4:22 AMseancorfield
seancorfield
bockensm
10/05/2022, 4:23 AM