takashi-ishio / selogger

(Near-)omniscient debugging/tracing/logging tool for Java
Other
35 stars 8 forks source link

Case of double and float primitive types is not handled #30

Closed prakharporwal closed 1 year ago

prakharporwal commented 1 year ago

Possible reason

eg. Actual : double a = 4614455732198220759L

Expected : a = 3.23d

using Double.longBitsToDouble() while writing into serialised value can fix this;

takashi-ishio commented 1 year ago

Thank you for the information. While the logger correctly translates primitive double/float values into long values during writing, Event.toString() did not decode the values into the original double/float values. As a result, you saw long values (e.g. 4614455732198220759L) in the textual output from LogPrinter.

To solve the issue, I have fixed Event.toString().

If you are directly manipulating Event objects in your program, please check the return value of getValueDesc() and call getFloatValue() or getDoubleValue() as the Event.toString() method does.