I am currently working with Oracle Siebel software which supports JavaScript expressions using only specific operators such as multiply, divide, subtract, add, and XOR (*
, /
, -
, +
, ^
). Unfortunately, other operators like !
or ? :
are not available for use.
Given the limited set of operators mentioned above, I am trying to figure out if it is possible to convert a number to 1 if it is non-zero, and keep it as 0 if it is already zero. This number can be positive, negative, or zero itself.
For example:
var c = 55;
var d; // d needs to be set as 1
I attempted using c / c
, however, this results in NaN
when c
is 0. In that scenario, d
should remain 0.
The value of c
represents a currency amount, meaning it will have up to two decimal places and a maximum of 12 digits before the decimal point.
My objective is to simulate an if
condition by converting a number into a Boolean 0 or 1, and then incorporating it into other parts of the expression.