Skip to main content

Hi,

I was formating big date numbers and I encountered a strange rounding effect when evaluating a big float number (see screenshot below). It can lead to issues when formating a datetime as FME needs seconds to be within 0 and 59 (60 not allowed).

As a workaround, I do the flooring using attributesplitter on strings (separator .).

However I wanted to ask whether this behavior is correct? I believe this is due to the size of the number.

Thanks for your answer

It's not strictly speaking an fme issue, you would see the same output if you performed the same expression in python. It is related to the way the computers store numbers

https://floating-point-gui.de/

An alternative to the attribute splitter is to use an AttributeCreator/AttributeManager and a ReplaceRegEx statement to replace anything after the decimal and including the decimal point with nothing

e.g.

@ReplaceRegEx(@Value(number),\.<0-9]*,"")

It's not strictly speaking an fme issue, you would see the same output if you performed the same expression in python. It is related to the way the computers store numbers

https://floating-point-gui.de/

An alternative to the attribute splitter is to use an AttributeCreator/AttributeManager and a ReplaceRegEx statement to replace anything after the decimal and including the decimal point with nothing

e.g.

@ReplaceRegEx(@Value(number),\.<0-9]*,"")

Thank you for the quick answer.


Good question. Another thing you could do is run the features through a DateTimeConverter transformer with the option set to repair overflow. Then if you do get a "60" seconds, it will be changed to the properly time.

This article explains in a bit (well, lot) more depth: https://knowledge.safe.com/questions/108860/question-of-the-week-number-rounding-errors-in-dat.html


Good question. Another thing you could do is run the features through a DateTimeConverter transformer with the option set to repair overflow. Then if you do get a "60" seconds, it will be changed to the properly time.

This article explains in a bit (well, lot) more depth: https://knowledge.safe.com/questions/108860/question-of-the-week-number-rounding-errors-in-dat.html

Deja vu - I'm sure @david_r posted this same answer on this same question earlier in the week but i don't see it now


Reply