eScript: Bitwise operations fail for certain negative numbers (Doc ID 2046421.1)

Last updated on AUGUST 24, 2015

Applies to:

Siebel Tools - Version 8.1.1.14 [IP2014] to 15.2 [1P2015] [Release V8 to V15]
Information in this document applies to any platform.

Symptoms

 Bitwise operators in eScript can produce wrong results.

Environment:

So far, the issue has been observed with the following versions:

Expected Behavior:

Bitwise operators should work as documented.

Actual Behavior:

The operators &, |, <<, >> fail if the input is smaller than the smallest negative 32-bit singed integer value (-2147483648).

Example: 

Operation: -2147483649 & 0xffffffff

Expected value: +2147483647

Observed value: -2147483648 

Steps:

The issue can be reproduced at will by passing a number smaller than -2147483648 to one of the bitwise operators. 

Side Note about bitwise operators and number formats:

In eScript, as well as in standard JavaScript, the bitwise operators work on 32-bit signed integer variables. The JavaScript standard has only one numeric data format, floating-point numbers. So for bitwise operations, numeric values are coerced into 32-bit signed integer format. In some situations, for example, in scripts that calculate hash sums like SHA256, the results of bitwise operations need to be summed up. The + operator treats the operands as normal numbers, so the result can be outside the range of 32-bit signed integers. To coerce such a result back to 32-bit, operations like "& 0xffffffff", "| 0", ">> 0", etc., are commonly used. All bitwise operators convert their input(s) into 32-bit signed integer format before applying the operation. 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms