Menu

Integer overflow bug in IEEE1516eHLAfloat64Time

2014-04-03
2014-04-05
  • Paul Grogan

    Paul Grogan - 2014-04-03

    The compareTo method has a bug in IEEE1516eHLAfloat64Time under OHLA 0.6, if the rhs time exceeds the maximum integer value, the result can overflow to negative values giving the opposite return value as expected.

    Recommended change from:

    return (int) Math.round(time - rhs.getValue());

    to:

    return new Double(time - rhs.getValue()).intValue();

    to safely cast the integer result.

     
  • Michael Newcomb

    Michael Newcomb - 2014-04-03

    Thanks for the bug report.

    I updated all the compareTo() methods to use Long.compare() and Double.compare().

     
  • Paul Grogan

    Paul Grogan - 2014-04-04

    Thanks! Would it be helpful to use the bug tracker in the future? I would have posted it there but didn't seem to have been updated in a while (and didn't seem to have the correct version in the drop-down).

     
  • Michael Newcomb

    Michael Newcomb - 2014-04-05

    There is not a lot of bug traffic, so, posting here is just fine. I'll try to update it so that if someone does try to use it, at least it will be up-to-date.

     

Log in to post a comment.