News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Divide by zero

Started by Farabi, September 17, 2011, 04:43:27 AM

Previous topic - Next topic

Farabi

Okay I am stupid, I though that everything divided by zero have to be zero because everything mul by zero must be zero.

So lets take an example.

1/10 = 0.1
but 1/(0.1)=10

So the conclusion is, the tinier the divisor, the bigger the result.
Lets take another example

1/(1/100) Also you can type it as 1/(0.01) it will yield result 100
So do 1/(0.00000001) it will result 10000000

So what it we divide it with zero? Yes. It would be infinity. I was stupid, really stupid. I know this when I on hi-school but never understand it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Vortex

Hi Onan,

The result of division by 0 is undefined :

x \ 0 = not defined   ( x is a member of the real number set. )

You need to careful with zero. Consider this :

0 \ 0 = ? ( again undefined )

0 \ 0 = 0 is false. Here is a trick :

( 0 \ 0 ) * 5 = ( 0 \ 0 ) * 10

0 * 5 = 0 * 10     ->  0 * 5 = 0    ,    0 * 10 = 0

Trying to simplify by 0 ( division by 0 ) :

5 = 10 or 1 = 2 which is not true.

Working on the division by 0 problem, the correct approach is to use limits :

lim x -> 0+  ( a \ x ) = + ∞

lim x -> 0-  ( a \ x ) = - ∞

lim x -> 0  ( a \ x ) = undefined

Some examples :

i) lim x -> 0+  ( a \ x ) = + ∞

5 \ 0.001 = 5000

5 \ 0.000001 = 5000000

5 \ 0.0000000001 = 50000000000

...

ii) lim x -> 0-  ( a \ x ) = - ∞

5 \ -0.001 = -5000

5 \ -0.000001 = -5000000

5 \ -0.0000000001 = -50000000000

...




jj2007

Or watch in Olly what you get - it's called a BAD number :bg
include \masm32\include\masm32rt.inc

.code
start: fldz
fldz
fdiv
exit
end start

dedndave

technically, any value divided by zero is "undefined"
however, in calculus, it is sometimes convenient to assign it a value of correctly signed infinity   :P

mineiro

Zero means "nothing", but is represented as one simbol. Zero are hold places simbolics.


Farabi

Vortex:
:U Thank I think I got it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

vanjast

Quote from: dedndave on September 17, 2011, 11:40:27 AM
however, in calculus, it is sometimes convenient to assign it a value of correctly signed infinity   :P
.. a defined 'indefinite'...  :eek

if you think of it 'logically'..

If you take something, and you divide it into zero pieces... you end up with either 1 or 0 pieces (hence Binary is the way  :green2),... not suddenly a gazillion pieces. (This sort of thing only happens in magical biblical scripts)  :bg

Vortex

Hi vanjast,

QuoteIf you take something, and you divide it into zero pieces... you end up with either 1 or 0 pieces (hence Binary is the way  ),... not suddenly a gazillion pieces. (This sort of thing only happens in magical biblical scripts)

Nice comment. You reminded me Schrödinger's cat remaining both alive and dead.

vanjast

It could mean that what you observe is actually 'what is', and visa versa..
:wink

xanatose

I guess, it would also depends on the set of data.

Consider the formula for RSI (relative strength index).


RSI = 100 - 100/(1 + (Average Gain / Average Loss))


Which gives a value between 0 and 100 inclusive.

What happens if there is no loss in the set of data. Sure one can go to the undefined route here. But what I do instead is:


if(0 == Average Gain) {
  if(0 == Average Loss) {
    RSI = 50;
  } else {
    RSI = 0;
  }
} else if(0 == Average Loss) {
  RSI = 100;
} else {
  RSI = 100 - 100/(1 + (Average Gain / Average Loss))
}

Mathematically incorrect. But avoids a division by zero,while giving a usable result.

If the average gain is equal to the average loss, then RSI = 50
If the average gain is zero, the RSI is zero.
If the average loss is zero, then RSI will tend to its maximum value 100
Otherwise use the formula.

daydreamer

put on Pet Shop boys "divide by zero" while solve is:)
so if I have a divide inside an algo, I say I need to define divide by zero etc by what works best for what is best to produce from that algo
a related problem is also trigo tan endsup to be 90 degrees