Skip to Content
0

Why does BODS casting to int of value '.000' returns 1 and not 0?

Oct 10, 2016 at 12:54 PM

62

avatar image

$i = cast('.0000', 'integer');

print('Int implicit conversion : ' || $i);
Returns 1

while

$i = cast('0.0000', 'integer');

print('Int implicit conversion : ' || $i);


Returns 0

Is there a reason or explanation as to why BODS assumes that no leading integer = 1?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

avatar image
Former Member Oct 12, 2016 at 01:38 PM
0

There is no way it would give the above results.. please make sure to define the variables with the proper datatype.

Share
10 |10000 characters needed characters left characters exceeded
Julien Lejeune Oct 27, 2016 at 01:34 PM
0

$i is a global variable declared as int , bods version is 14.2.6

Share
10 |10000 characters needed characters left characters exceeded
Aasavari Bhave
Oct 27, 2016 at 04:13 PM
0

I see the odd behavior:

$i = cast('.0000', 'integer'); returning 1. Will investigate and update

,

$i = cast('.0000', 'integer'); return1 - I just noticed that. Will investigate further and update.

Share
10 |10000 characters needed characters left characters exceeded