Skip to Content

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

$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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

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

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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2016 at 01:34 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2016 at 04:13 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded