 # A virtual column gives 0.0000 from formula 1/2

The virtual column is decimal type having 4 decimal digits. given result is The expected result is 0.5000.

Why?

1 Like

Please try

1/2.0000 as app formula.

2 Likes
4 Likes

Thanks but regret to say that it does not answer my question.

Division with integers ( 1/ 2) , will have integer result. (0)

Dividing by 2.0000 brings in decimal division. Number of decimal points in denominator will give decimal points in answer. Division by 2.0 will result in 0.5

4 Likes

Read the document I refered to .

2 Likes

Thank you very much.

1 Like
2 Likes

Thanks Steve. If an expression contains [columns], the result seems ok. In my case there was pure numbers with operators, adjusting the decimal points of virtual column does not help showing the expected value.

Anyway that was just my experiment, there is no use in real apps.

What does this have to do with anything?

1 Like

All this started from my curious of how AppSheet prioritizes the math operators in calculations (I have not seen any documentations mention about it).

To check if 1-1/2 returns 0.5 (like scientific calculators) or 0 ? I created a virtual column to test it. The result was 0. But I could not conclude that the result 0 was from calculation or from displaying behavior.

If AppSheet does scientific way, I will not use extra ( ) in my expressions.

1 Like

AppSheet applies common math order of operations, but order of operations is not the problem with your expression.

2 Likes

To make things clear, what are the results from this following expressions in AppSheet?

[column a]-[column b]/2 =?

[column a]-([column b]/2) =?

([column a]-[column b])/2 =?

If the values of [column a] and [column b] are 1.

What are the column types of column a and column b?

2 Likes

Absolutely decimal type.

Then I would expect:

• `[column a]-[column b]/2` to give 0.5

• `[column a]-([column b]/2)` to give 0.5

• `([column a]-[column b])/2` to give 0

But if they are instead of type Number:

• `[column a]-[column b]/2` would give 1

• `[column a]-([column b]/2)` would give 1

• `([column a]-[column b])/2` would give 0

2 Likes

Thank you 2 Likes