TextToInteger vs TextToDecimal

Got bitten by a mismatching pair of platform functionality:

Now I'd like to know why there's a difference on parsing numeric values expressed as text between these two platform provided functions:

TextToInteger("200.482") = 0

and

TextToDecimal("200.482") = 200.428

Decimal parsing makes sense, but for integer, I cannot see any reason why 0 is returned instead of nearest integer value. Can somebody explain this decision to me?

Edit: I know I can DecimalToInteger(TextToDecimal("200.482")) to get my expected result (=200 in this case). This is not what I'm asking.

Solution

Hello Mikko,

Since the number 200.482 is not an integer, then it will return 0. In fact, 200.482, is a decimal.

Following the documentation, it's also the possibility that first the function check if the conversion is possible using TextToIntegerValidate function internally, checking that's false, then it will return 0.

Regards.

Solution

Tiago Gomes wrote:

Hello Mikko,

Since the number 200.482 is not an integer, then it will return 0. In fact, 200.482, is a decimal.

It's how things work. I believe there's no "extra-explanation" for this case, specifically.

Regards.

Yes, this is valid way of thinking but makes no sense to me in the context of parsing a number from input text -especially when there's separate functions to validate if given piece of data can be interpreted as decimal/integer.

I'd presume all parsing of numbers in the platform would go through the same pipe (input -> decimal -> integer)

My thinking goes: "give me an integer out of this data if the only content is number with valid decimal / thousands separators."

Platform seems to think: "give me an integer if this piece of data is already a valid integer"