Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on December 21, 2021 5:47PM
Likes: 0
Replies: 2
Hi,
In prepare recipes, when coded values are split up, it can happen that you end up with values like "1d", "1f" or "2e6". Testing and processing these values might give unexpected results when column values are not read with some care, see attached screenshot :
1d and 1f-values get changed into something else because i did not read those values as string, it would not have happened if i had used concat(strval("col_0"),"5") as formula for col_1. So a solution is available and note is taken to keep this in mind when splitting values. I just don't understand why this happens in the first place, can anyone comment on that ?
Operating system used: Ubuntu 18.04
Hi,
The val() function evaluates the value of a column, flexibly registering the type in Java. You're correct to point out that strval() evaluates the column value only as a string. val() is more flexible.
Numeric characters followed by a singe "f" or "d", e.g. 1f, 1d, are special, in that Java indeed registers these as numbers of the float or decimal type.
In your examples, "1f" is first changed to "1.0" (decimal added because of float type), and "1d" is also changed to "1.0" for the same reason. Then, your subsequent step concatenates the "5" to "1.0" - hence "1.05".
Note that this only happens when numeric characters are followed by a single "f" or "d" at the end. Trailing "ff" and "dd", or single "f" or "d" mixed in the middle of numbers won't see the same behavior.
Best,
Pat
Thank you @pmasiphelps
!
This is one of those little things to keep in mind when referencing column-values.. I had some pretty strange results after splitting up and further processing of codified values (nitrogen storage locations, don't want to get those wrong) when i did that carelessly with just val() instead of strval().
Cheers!
Jurre