Precision / Rounding error

After running into problems with a network yesterday I narrowed down the problem to a possible (likely) precision/rounding error. Can anyone suggest a fix/work around for this please?

The problem is illustrated by this network - it’s a simple list generation that I use for subdividing other geometry, it should generated a list of n+1 numbers between 0 and 1 where n is the number of sub-divisions I specify. However, where the number of subdivisions generates a step size that is a recurring decimal there is a rounding error and the last element of the list (1.0000) is not generated.

I can add in some basic error checking to check if the last element is 1.000 and if not add it in but that seems like something that I shouldn’t have to do. Are there plans to increase the level of precision in future releases of Dynamo?

 

 

It isn’t a rounding/precision issue

This alternate approach should hopefully explain the problem while providing a solution…

20160407-4

Well that helps but to me that totally defeats the point of having a visual tool, if we’re just going to script it anyway then what’s the point?

A similar result with available nodes (though I wouldn’t really suggest taking this approach)

20160407-4a

 

I guess my question is, why isn’t the Range node coded internally as start…end…~(step); as that’s the output I would expect it to produce, not sometimes produce the number of elements I expect and other times not. To me this makes the Range node redundant and I won’t be using it again in favour of a code block that does what I expect it to do.