I'm working with a virtual column whose type ...

expressions
(Kirk Masden) #1

I’m working with a virtual column whose type is “Number” and have been having trouble getting decimals to calculate properly.

If I use “1/3” in an expression the result of the calculation is “0”.

If, however, I type the expression as “1/3.00”, which should produce the same result, I get “0.33”.

Can anyone tell me what is going on?

I want “0.33,” so I’m happy with the result now, but I wonder if I have to type something like “1/3.00” to get the calculation to work properly or if there’s some other issue of which I’m not aware. Also, Is this issue unique to virtual columns?

(Kirk Masden) #2

Now I see that the truncation of integers has been discussed before:

“Looks like you’re getting “integer division” - because both inputs are integers the expression type system infers the output should be an integer, and 55/60 truncated to the nearest integer is 0.” – Adam Stone

https://plus.google.com/+MultitechVisions/posts/2JkMZC86LcC

I guess the solution I happened to find is a known workaround.

Nonetheless, it’s not at all intuitive and I couldn’t find anything about it in the “Math Expressions” documentation.

I would suggest that the issue be fixed in some way or that documentation be improved.

(Levent KULAÇOĞLU) #3

@Kirk_Masden

In general programming interface there isn’t an integer and/or decimal concept. Instead there are number and float concepts matching them. Therefore, for example in Java or JS, when you log (1/3) you get a 0. But if you use float(1/3) then you get a 0.33 value. The concept in AppSheet is pretty much the same.

(Kirk Masden) #4

Thank you, @Levent_KULACOGLU!

This has been a good learning experience for me.

For AppSheet, however, I think more/better documentation is needed because I think the whole idea is for the platform to be easy to use for people who are not programmers.

Thanks to you, though, my own issue has been resolved.

(Aleksi Alkio) #5

@Kirk_Masden We should explain this better, that’s true. +Steve Coile FYI