You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Snowmans template system currently provides a series of math related functions like add, add1, sub, div, mul, mod, and rand. All of these only operate on whole numbers, if given a non whole number it will be cast to an integer before operated on.
Imagine the snippet div 2.9 3. Before 2.9 is operated on it's cast to 3, the result therefore becomes 0.
This limit developers options to work with floating values, a few have the option to do operations on floats directly in their SPARQL queries but that's not an option for all.
Suggestion
I'm leaning towards making all the math functions default to working with floating values, so that div 2.9 3 returns 0.966666666667.
If need be one would be able to reproduce the old behavior by doing something like div (int 2.9) 3, but it's still a breaking change that I think would have an impact on many projects.
Thoughts or concerns regarding the proposed changes are very welcome!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Background / problem
Snowmans template system currently provides a series of math related functions like
add
,add1
,sub
,div
,mul
,mod
, andrand
. All of these only operate on whole numbers, if given a non whole number it will be cast to an integer before operated on.Imagine the snippet
div 2.9 3
. Before2.9
is operated on it's cast to3
, the result therefore becomes0
.This limit developers options to work with floating values, a few have the option to do operations on floats directly in their SPARQL queries but that's not an option for all.
Suggestion
I'm leaning towards making all the math functions default to working with floating values, so that
div 2.9 3
returns0.966666666667
.If need be one would be able to reproduce the old behavior by doing something like
div (int 2.9) 3
, but it's still a breaking change that I think would have an impact on many projects.Thoughts or concerns regarding the proposed changes are very welcome!
Beta Was this translation helpful? Give feedback.
All reactions