# prepare recipe turns number/lettercombo to numeric

Solved!
Level 5
###### prepare recipe turns number/lettercombo to numeric

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 :

• col_0 is given
• test_0 tests the value col_0 if it's numeric
• col_1 concatenates the value of col_0 with "5"
• test_1 tests the value of col_1 if it's numeric.

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 ?

isNumeric

Operating system used: Ubuntu 18.04

1 Solution
Dataiker

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

2 Replies
Dataiker

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

Level 5
Author

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