1 2 Previous Next 19 Replies Latest reply on Jul 19, 2015 8:52 AM by beverly

# Indeterminate form of division

Just came across a rather peculiar thing in a calculation field.

While trying to calculate an average value based on two fields, all both number fields:

Let's call it average = total / qty.

When both fields have a value of zero the calculation result is ?. Yes, a question mark.

From what I could find it's called in mathematics an "indeterminate form of division"

I was rather expecting ( hoping for ) a zero .

But it's a trap for young players, like myself. Especially if you count on that number to use somewhere else.

So why not get it out in the open...

• ###### 1. Re: Indeterminate form of division

https://en.wikipedia.org/wiki/Division_by_zero

There is no answer for a "divide by zero", so zero is not the right answer...

• ###### 2. Re: Indeterminate form of division

It's a good reminder to always check your inputs for plausibility before you do something with it.

• ###### 3. Re: Indeterminate form of division

Total and/or qty could be negative or otherwise less than 0 and your test would not be valid.

-- sent from myPhone --

Beverly Voth

--

• ###### 4. Re: Indeterminate form of division

Exactly.  Check your inputs before you try to operate on them.

• ###### 5. Re: Indeterminate form of division

Since division by zero is indeterminate (see wim's post) you need to rework your formula to account for the possibility, e.g.:

Let (

[

numerator = 120 // or any number field

; denominator = 0 // or any number field

; result = If ( denominator = 0 ; "" ; numerator / denominator )

] ;

result

)

The above expression will leave the result blank instead of with a ? mark. And by the way, your statement "When both fields have a value of zero the calculation result is ?" is not correct. It is only the zero denominator that is producing the ?. A zero numerator will result in zero.

• ###### 6. Re: Indeterminate form of division

If you have access to an iPhone, ask Siri the question: "Siri what is zero divided by zero?"

Siri responds with an entertaining answer.

The YouTube clip is here if you don't have an iPhone.

Michael Richards

Brisbane (Australia)

• ###### 7. Re: Indeterminate form of division

keywords wrote:

And by the way, your statement "When both fields have a value of zero the calculation result is ?" is not correct. It is only the zero denominator that is producing the ?. A zero numerator will result in zero.

You're totally right . dividing by zero makes no sense.

• ###### 8. Re: Indeterminate form of division

Thank you Wim & Beverly. That's what I was looking for.

I need to catch the exception before it happens and not after, based on input.

qty and total myst be able to hold zero instead of null.

Can't mark the right answer, only report abuse. None going on here.

• ###### 9. Re: Indeterminate form of division

I ended up with this:

Case (

IsEmpty ( total ) or total = 0 ; 0;

total / qty

)

All fields are stored so I don't mind evaluating the total twice.

And I need the result to show a number even if zero.

• ###### 10. Re: Indeterminate form of division

electon wrote:

Case (

IsEmpty ( total ) or total = 0 ; 0;

total / qty

)

Shouldn't you rather check whether qty is 0 or empty?

• ###### 11. Re: Indeterminate form of division

still not quite right. You cannot divide by 0. 'total' can be empty or 0, 'qty' cannot.

beverly

On Jul 19, 2015, at 7:13 AM, electon <noreply@filemaker.com> wrote

Indeterminate form of division

reply from electon in Discussions - View the full discussion

I ended up with this:

Case (

IsEmpty ( total ) or total = 0 ; 0;

total / qty

)

All fields are stored so I don't mind evaluating the total twice.

And I need the result to show a number even if zero.

• ###### 12. Re: Indeterminate form of division

electon wrote:

But it's a trap for young players, like myself.

If memory serves, it was Elementary School where I was taught that dividing by zero is no meaningful arithmetic operation; how's that for “young player”?

• ###### 13. Re: Indeterminate form of division

I just knew sooner or later it's gonna come up.

What I meant is that filemaker did't make an assumption and make the result a zero, which is correct behaviour.

The assumption was on my part.

Elementary was "A long time ago in a galaxy far, far away..."

• ###### 14. Re: Indeterminate form of division

electon wrote:

What I meant is that filemaker did't make an assumption and make the result a zero, which is correct behaviour.

“Correct behaviour”? Not really …

1 2 Previous Next