# Photoshop General Discussion

Currently Being Moderated

## Why does Photoshop consider 0 divided by 0 to be 0?

### Feb 7, 2013 6:15 AM

Why does Photoshop reckon 0 divided by 0 is 0 when doing arithmetic with colour components?

I guess the program logic assumes 0 divided by anything is 0, never proceeding as far as considering that a divisor of 0 is involved. But I wonder if this handling of 0 / 0 is deliberate for a reason that eludes me.

For a non-zero number divided by 0, Photoshop produces the maximum value of a colour component (e.g. 255 in 8 bits). That is sensible and the same result should arise from dividing 0 by 0, surely. (Other graphics software does consider 0 / 0 to produce max.)

Look at the contrived example below. The black disc in Divide mode should result in a white disc, but wherever an underlying colour component is 0, the resulting colour component is 0 instead of max. (Don't bother measuring the pixels in the screenshot - they've been converted from sRGB to my display profile then to sRGB again without infinite precision.)

Replies
• 23,526 posts
Dec 23, 2006
Currently Being Moderated
Feb 7, 2013 9:48 AM   in reply to conroy

Interesting thoughts.

Whenever exploring limits of software, I tend to think about what happens BETWEEN and NEAR the limits.

As a test I created a document along the lines of what you did, then added a Curves layer clipped to the Gradient fill layer.  I noted the behavior of the result as I made the gradient layer darker.  The output stayed maxed-out right up until the curves reached zero (meaning all the pixel data passed up to the layer with Divide blending were (0, 0, 0), at which point the result just went to black, confirming what you're seeing.

Then I tried setting the color of the layer with Divide blending to a little above black (non-zero).

Note the consistency between these results, both creating maxed-out colors and ending up at black once the layers below delivered (0, 0, 0) pixel values.

These things came to mind:

Since 0/0 is undefined, mathematically (it becomes a philosophical question leading ultimately to brain freeze in the cold vacuum of space ), an exception must be chosen.

Which of these does Adobe choose?

• Anything divided by 0 is infinite.
• 0 divided by anything is 0.

Is there a reason they have to choose just one?  It's a computer, after all, and can make decisions.  Maybe they made choices based on what made for the most interesting results, artistically.  Maybe it's actually something in between that seems to make artistic sense.

-Noel

|
Mark as:
• Currently Being Moderated
Feb 7, 2013 10:20 AM   in reply to Noel Carboni

0/0 is not always considered infinite: (sin(x)/x) -> 1 as x -> +-0.

(a function Noel should be familiar with :-)

And as Noel guessed, the choice is by design because in many instances it provides better continuity in the visual results.

|
Mark as:
• 23,526 posts
Dec 23, 2006
Currently Being Moderated
Feb 7, 2013 10:33 AM   in reply to Chris Cox

Actually, I specifically said 0/0 is undefined, not "infinite".  Perhaps I should have said "indeterminate" or "NaN".  But I do support your artistic choice in this case, Chris.

Conroy, think of it as a "channel clipping detector".

-Noel

|
Mark as:
• Currently Being Moderated
Feb 7, 2013 10:40 AM   in reply to conroy

Depending on the context, 0/0 can be considered zero, one, positive infinity or negative infinity.

It depends on the specific context and what you are trying to provide continuity with.

P.S. I'm not the only admin here.

|
Mark as:
• Currently Being Moderated
Feb 7, 2013 10:48 AM   in reply to conroy

I'm active in the forums almost all day, even when not posting here.

|
Mark as:
• 23,526 posts
Dec 23, 2006
Currently Being Moderated
Feb 7, 2013 11:31 AM   in reply to conroy

conroy wrote:

Noel Carboni wrote:

Conroy, think of it as a "channel clipping detector".

Nope, I'll continue to think of it as a mistake.

Suit yourself, but honestly in no place in the world would one interpretation of "zero divided by zero" be considered any more or less a "mistake" than others.

You seem to have the thought that Photoshop should be implemented per your idea of what makes sense.  In my thinking it's kind of like criticizing the designer of a socket wrench for not handling a particularly long bolt.  Your thought to use another tool for getting the results you need in a specialty situation - akin to using a socket wrench specificallly designed for deep operation - is reasonable.

What application of "Divide" blending had you envisioned where you needed it to work in a different way than it actually does?  The obvious thing is to try to think of another way to do that operation.

-Noel

|
Mark as:
• 23,526 posts
Dec 23, 2006
Currently Being Moderated
Feb 7, 2013 4:17 PM   in reply to conroy

Clearly those other programs are doing it "wrong", considering which program is known to be the primo editing tool and sells for the big bucks.    We could go on and on.  Perhaps Adobe needs to create an alternate Divide mode (or better yet a "roll your own" blender).  Clearly they can't change something that may be built into millions of PSD files already.

I never did figure out what mantralightroom wants from his whites.

-Noel

|
Mark as:
• Currently Being Moderated
Feb 7, 2013 7:18 PM   in reply to Noel Carboni

In my Advanced mathematics class (calculus) zero was defined as a number so small that it could not be measured, being the opposite of infinity which is a number so large it cannot be measured.

So zero divided by zero could be anything.

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers