#744 HNum encoding in Java Toolkit

Madhushan Tennakoon Thu 3 Oct 2019

Hi all,

This is regarding the Haystack Java Toolkit.

We noticed that the HNum class encodes 0 and 1 as doubles and all other whole numbers as integers. Floating-point values are encoded as expected:

0 --> 0.0

1 --> 1.0

2 --> 2

42 --> 42

75.5 --> 75.5

Here's the link: HNum

Just checking to see if this is expected behavior. If this is a duplicate of an issue, kindly point to the relevant thread.

Thanks.

Brian Frank Thu 3 Oct 2019

Its just an optimization to semi-pretty print larger floats:

// don't encode huge set of decimals if over 1.0
double abs = val; if (abs < 0) abs = -abs;
if (abs > 1.0)
  s.append(new DecimalFormat("#0.####", 
       new DecimalFormatSymbols(Locale.ENGLISH)).format(val));
  else
    s.append(val);

It shouldn't have any impact in behavior

Madhushan Tennakoon Thu 3 Oct 2019

Thanks for clarifying Brian.

Login or Signup to reply.