If I send the result of a calculation to a lookup subtable as a line number and the calculation doesn't produce a whole number, how does IPP handle it?
Thank you. This is similar to my results. As I only need to pass the calculation result if it is a whole number I'll have to devise an interim routine to test it.
IPP is written in Delphi, and I believe their rounding function by default uses what's called "Banker's Rounding", where it rounds to the nearest even number. That's probably whats going on there.
Comments
From what I can tell, using lookup values with anything other than a positive whole number is quirky.
Example: This always returns "one"
Table: Test
{roll=1d3+0.5} yields [#{roll} Look]
Table: Look
Type:lookup
default:default
1:one
2:two
3:three
Example: This always returns "default"
Table: Test
{roll=1d3+0.5} yields [#{roll} Look]
Table: Look
Type:lookup
default:default
2:two
3:three
Thank you. This is similar to my results. As I only need to pass the calculation result if it is a whole number I'll have to devise an interim routine to test it.
You could use round, floor, or ceil either to turn the result into a whole integer or to test it.
[#{round(roll)} Look]
or
[when]{floor(x)}={x}[do]It's a whole integer[else]It's not a whole integer[end]
One catch: I just found out that the round function isn't always right. In this example, it rounds 1.5 and 3.5 correctly, but not 2.5.
That's either a quirk of the internal floating point representation or a bug in the round function.
Thanks for your suggestions and examples. I did a combination of the two examples and so far it's working OK.
IPP is written in Delphi, and I believe their rounding function by default uses what's called "Banker's Rounding", where it rounds to the nearest even number. That's probably whats going on there.