How to represent infinity in the StreamBase 'double' data type

How to represent infinity in the StreamBase 'double' data type

book

Article ID: KB0075201

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

How can I represent a value of infinity using the StreamBase 'double' data type?

Resolution

For +Infinity, -Infinity (and NaN), the StreamBase 'double' data type works analogously to the Java 'Double' type as described in the Java API Documentation, and allows +Infinity and -Infinity (and NaN) as possible values. Consider the following examples..

NOTE: The use of 'sbd -e' to evaluate simple StreamBase Expression Language functions is replaced in TIBCO Streaming by using SB Studio's menu Help > Evaluate StreamBase Expressions...

Division by a value close to epsilon results in Infinity:
C:\>sbd -e "(1 / 1E-323)
(double) Infinity

..or negative infinity:
C:\>sbd -e "(-1 / 1E-323)"
(double) -Infinity

..but smaller than epsilon is zero:
C:\>sbd -e "(1 / 1E-324)"
error: Evaluation exception: Division by zero

Infinity equals Infinity:
C:\>sbd -e "(1 / 1E-323)==(2 / 1E-323)"
(bool) true

Infinity minus Infinity is NaN:
C:\>sbd -e "(1 / 1E-323) - (1 / 1E-323)"
(double) NaN

The expected boolean comparisons all work with these special values.

Functions:
$ ./bin/sbd --eval "positive_infinity()"
(double) Infinity
$ ./bin/sbd --eval "negative_infinity()"
(double) -Infinity
$ ./bin/sbd --eval "negative_infinity() < positive_infinity()"
(bool) true
$ ./bin/sbd --eval "nan()"
(double) NaN

 

Issue/Introduction

How to represent infinity in the StreamBase 'double' data type