f

#### (= 0/0 0/0)

```Hi,

shouldn't

> (= 0/0 0/0) => NIL

or

> (= 0/0 0/0) => T

instead of giving out division by zero?  0/0 is different from 1/0,
which is the non-existent number n such that 1 x n = 0.

The actual result of that expression depends of what you think 0/0 is.

I personally feel that 0/0 is any number n such that 0 x n = 0, that
is all numbers.
```
 0
hal9 (12)
12/11/2003 6:57:42 PM
comp.lang.lisp 16861 articles. 5 followers.

11 Replies
2636 Views

Similar Articles

[PageSpeed] 36

```hal9@cyberspace.org (Hal Niner) writes:

> Hi,
>
> shouldn't
>
> > (= 0/0 0/0) => NIL
>
> or
>
> > (= 0/0 0/0) => T
>
> instead of giving out division by zero?  0/0 is different from 1/0,
> which is the non-existent number n such that 1 x n = 0.
>
> The actual result of that expression depends of what you think 0/0 is.
>
> I personally feel that 0/0 is any number n such that 0 x n = 0, that
> is all numbers.

This is probably the difference between mathematics and engineering.

When I see 0/0, what I see is "this is a program bug".  The place "any
number" comes into my thinking is the sense in which I think "any number
I put here would have been just as bad".

In practice, the most likely place you'll see 0/0 is

(/ (reduce #'+ y) (length y))

where y is null.  And I can tell you, I don't want Lisp returning any
old number and having my table of average incomes say

Residents   Average Yearly Income
---------   ------------------
0         \$ -9,347,425.36

just because -9347425.36 x 0 = 0.

It's an error because the programmer needs to know it's an error.
Mathemeticians can do their own handling, but me in this case, I want
"---" to come back, and I don't see any way that / all by itself is
going to know to do that.

Or if what you want is the literal rational 0/0 to do something different
than the function call (/ 0 0), then I don't like that for several reasons,
at least one of which is "it's irregular" and makes it hard to express the
rules for rational simplification.
```
 0
pitman (1396)
12/11/2003 7:18:31 PM
```hal9@cyberspace.org (Hal Niner) writes:

> Hi,
>
> shouldn't
>
> > (= 0/0 0/0) => NIL
>
> or
>
> > (= 0/0 0/0) => T
>
> instead of giving out division by zero?  0/0 is different from 1/0,
> which is the non-existent number n such that 1 x n = 0.
>
> The actual result of that expression depends of what you think 0/0 is.
>
> I personally feel that 0/0 is any number n such that 0 x n = 0, that
> is all numbers.

It depends on how you arrived to the 0 denominators.

(defun f (x) (sin x))
(defun g (x) x)
(defun h (x) (/ x 2))

(= (f 0) 0.0)
(= (g 0) 0.0)
(= (h 0) 0.0)

but    (= (lim x -> 0 (/ (f x) (g x))) 1)
while  (= (lim x -> 0 (/ (f x) (h x))) 2)

So you have 0/0 = 1 on the one hand, and 0/0 = 2 on the other hand
and clearly, 0/0 /= 0/0

Where do your zeroes come from?

--
__Pascal_Bourguignon__                              .  *   * . * .* .
http://www.informatimago.com/                        .   *   .   .*
There is no worse tyranny than to force             * .  . /\  ()  . *
a man to pay for what he does not                    . .  / .\   . * .
want merely because you think it                    .*.  / *  \  . .
would be good for him. -- Robert Heinlein             . /*   o \     .
http://www.theadvocates.org/                        *   '''||'''   .
SCO Spam-magnet: postmaster@sco.com                 ******************
```
 0
spam173 (586)
12/11/2003 9:14:24 PM
```hal9@cyberspace.org (Hal Niner) wrote in message news:<1533d93d.0312111057.c8222f@posting.google.com>...
> Hi,
>
> shouldn't
>
> > (= 0/0 0/0) => NIL
>
> or
>
> > (= 0/0 0/0) => T

No. You are using =, which is a function. A function has no access to
the argument forms, only to the results of their evaluation. The
argument list (0/0 0/0) is evaluated left to right before = is called.
During this evaluation, a division by zero occurs.

> instead of giving out division by zero?  0/0 is different from 1/0,
> which is the non-existent number n such that 1 x n = 0.

In Lisp, a number is an actual object, not the set of solutions to an
equation. When you divide two integers, the result must be a valid
rational number.

> The actual result of that expression depends of what you think 0/0 is.
>
> I personally feel that 0/0 is any number n such that 0 x n = 0, that
> is all numbers.

In that case, you have to implement your own arithmetic. The built-in
arithmetic that you get with Common Lisp is already probably more
complicated and robust than that of any other industrial programming
language.

In Lisp you can use the object system to define your own operators
like = + and so on in your own package, which are generic over all the
existing number types (i.e. backwards compatible with the built-in
functions over the existing combinations) and which extend to your own
kinds of numbers.

(defpackage :wacky-arithmetic
(:use :cl)
(:shadow :/ :=)) ;; note smiley

(in-package :wacky-arithmetic)

(defclass wacky-number () ...)

;; fall back on standard CL = for two ordinary numbers
(defmethod = ((left numbe r) (right number))
(cl:= left right))

;; handle comparison of WACKY-NUMBER with a RATIONAL
(defmethod = ((left wacky-number) (right rational))
...)

;; handle division of two rationals with zero denominator
;; to obtain special WACKY-NUMBER denoting that quantity

(defmethod / ((numerator rational) (denominator rational))
(if (zerop denominator)
(make-instance 'wacky-number ... wacky arguments ...)
(cl:/ numerator denominator)))
```
 0
kaz (293)
12/11/2003 11:23:55 PM
```There is actually a way of defining 0/0 as well as 1/0
which makes CL rational arithmetic simpler rather than
more complicated.
0/0 is essentially like a floating point NaN, and
1/0 is like an (unsigned) infinity. Though there is
an argument to allow -1/0 also...

remember...
a/b +c/d =  (ad+cb)/bd   reduced to lowest terms?
if a/b  is 0/0  you get ... 0/0 ...
if a/b  is 1/0   you get  (d+0)/0 .  reduce to lowest terms, 1/0
unless d is also 0, in which case you get 0/0

a/b* (c/d) =  (ac)/bd

works similarly.

So it may be that you have more special case checks to
exclude 0/0 and 1/0 than if you allow them.

I wrote this up some time ago.

is 0/0 = 0/0  ?  Just like (= NaN NaN).

Cheers.
RJF

Pascal Bourguignon wrote:

> hal9@cyberspace.org (Hal Niner) writes:
>
>
>>Hi,
>>
>>shouldn't
>>
>>
>>>(= 0/0 0/0) => NIL
>>
>>or
>>
>>
>>>(= 0/0 0/0) => T
>>
>>instead of giving out division by zero?  0/0 is different from 1/0,
>>which is the non-existent number n such that 1 x n = 0.
>>
>>The actual result of that expression depends of what you think 0/0 is.
>>
>>I personally feel that 0/0 is any number n such that 0 x n = 0, that
>>is all numbers.
>
>
> It depends on how you arrived to the 0 denominators.
>
> (defun f (x) (sin x))
> (defun g (x) x)
> (defun h (x) (/ x 2))
>
> (= (f 0) 0.0)
> (= (g 0) 0.0)
> (= (h 0) 0.0)
>
> but    (= (lim x -> 0 (/ (f x) (g x))) 1)
> while  (= (lim x -> 0 (/ (f x) (h x))) 2)
>
> So you have 0/0 = 1 on the one hand, and 0/0 = 2 on the other hand
> and clearly, 0/0 /= 0/0
>
> Where do your zeroes come from?
>

```
 0
fateman2 (359)
12/12/2003 1:35:36 AM
```>
>  (/ (reduce #'+ y) (length y))
>
> where y is null.  And I can tell you, I don't want Lisp returning any
> old number and having my table of average incomes say
>

I understand this, but shouldn't it be the case where taking a length
of a null list gives you some sort of error/warning/exception?

Oh, wait, no

(eq '() nil) => T

OK, then. ;)
```
 0
hal9 (12)
12/12/2003 1:47:47 PM
```hal9@cyberspace.org (Hal Niner) writes:

> >
> >  (/ (reduce #'+ y) (length y))
> >
> > where y is null.  And I can tell you, I don't want Lisp returning any
> > old number and having my table of average incomes say
> >
>
> I understand this, but shouldn't it be the case where taking a length
> of a null list gives you some sort of error/warning/exception?

did you mean to write "the false value" here instead of "a null list"?

> Oh, wait, no
>
> (eq '() nil) => T

stylistically, you are here comparing the empty list to the false value.
why that would be relevant to the question of whether you could take length
of the empty list, I don't know.   of course, if you'd been wondering why
you can take length of the false value, this remark would make perfect sense.

> OK, then. ;)

In spite of the smiley, I had the impression there was some unresolved issue
here, so i figured i'd explore it.

-----

Legitimately taking length of a null list is quite common, especially in
cases like:

(case (length x)
((0) ...)
((1) ...)
(otherwise ...))

(although I usually use a bounded-length operator for this these days,
so it doesn't waste time computing the number 347 as the length, only
to compare it to 0 and 1).

And in principle, you could do base cases of iteration as

(defun find-it (x list)
(cond ((= (length list) 0) nil)
(t (find-it x (cdr x)))))

[if we didn't mind find-it being O(n^2)].  It's for speed, in effect, that
we prefer (NULL x) to (= (LENGTH x) 0).   Though there are some aesthetic
benefits [like program termination] to having NULL available for writing
LENGTH itself.

```
 0
pitman (1396)
12/12/2003 3:01:45 PM
```Kent M Pitman <pitman@nhplace.com> writes:

> hal9@cyberspace.org (Hal Niner) writes:
>
> > >
> > >  (/ (reduce #'+ y) (length y))
> > >
> > > where y is null.  And I can tell you, I don't want Lisp returning any
> > > old number and having my table of average incomes say
> > >
> >
> > I understand this, but shouldn't it be the case where taking a length
> > of a null list gives you some sort of error/warning/exception?
>
> did you mean to write "the false value" here instead of "a null list"?
>
> > Oh, wait, no
> >
> > (eq '() nil) => T
>
> stylistically, you are here comparing the empty list to the false value.
> why that would be relevant to the question of whether you could take length
> of the empty list, I don't know.   of course, if you'd been wondering why
> you can take length of the false value, this remark would make perfect sense.
>
> > OK, then. ;)
>
> In spite of the smiley, I had the impression there was some unresolved issue
> here, so i figured i'd explore it.

I  think he  was refering  to the  fact that  there is  no distinction
between "null" lists and empty lists, ie. (eq (eq '() nil) t).

I don't know what  a "null" list would be. There could  be no list, an
empty list, or  some other, non empty, lists. In  Common Lisp, this is
expressed with indicators:

(defun what-kind-of-list-p (&optional (the-list nil given-p))
(cond
((not given-p)   :no-list)
((null the-list) :empty-list)
(t               :other-list)))

[39]> (what-kind-of-list-p)
:NO-LIST
[40]> (what-kind-of-list-p ())
:EMPTY-LIST
[41]> (what-kind-of-list-p '(a))
:OTHER-LIST

Or the  "no-list" case  could be represented  with a  special :no-list
token (in scheme we could use #f).

(defun what-kind-of-list-p (the-list)
(cond
((eq :no-list the-list)   :no-list)
((null the-list)          :empty-list)
(t                        :other-list)))

[46]> (what-kind-of-list-p :no-list)
:NO-LIST
[47]> (what-kind-of-list-p '())
:EMPTY-LIST
[48]> (what-kind-of-list-p '(a))
:OTHER-LIST

--
__Pascal_Bourguignon__                              .  *   * . * .* .
http://www.informatimago.com/                        .   *   .   .*
There is no worse tyranny than to force             * .  . /\  ()  . *
a man to pay for what he does not                    . .  / .\   . * .
want merely because you think it                    .*.  / *  \  . .
would be good for him. -- Robert Heinlein             . /*   o \     .
http://www.theadvocates.org/                        *   '''||'''   .
SCO Spam-magnet: postmaster@sco.com                 ******************
```
 0
spam173 (586)
12/12/2003 5:00:41 PM
```Kent M Pitman <pitman@nhplace.com> writes:

> hal9@cyberspace.org (Hal Niner) writes:
>
>> I understand this, but shouldn't it be the case where taking a length
>> of a null list gives you some sort of error/warning/exception?
>
> did you mean to write "the false value" here instead of "a null list"?

I suspect hal9 meant a null pointer as in C or Java, where it is
a special value that can be assigned in a variable of any pointer
type.

Common Lisp does not have such a construct.  It has the NIL
symbol, which is also the empty list and the false value; but it
is not automatically included in other types.  For example, if
you declare that a variable will always hold a STRING, then NIL
is not a valid value for it.  If you want to allow NIL too,
declare the type as (or string null), or just omit the
declaration altogether.
```
 0
kon (429)
12/12/2003 7:21:22 PM
```Kalle Olavi Niemitalo <kon@iki.fi> writes:

> Kent M Pitman <pitman@nhplace.com> writes:
>
> > hal9@cyberspace.org (Hal Niner) writes:
> >
> >> I understand this, but shouldn't it be the case where taking a length
> >> of a null list gives you some sort of error/warning/exception?
> >
> > did you mean to write "the false value" here instead of "a null list"?
>
> I suspect hal9 meant a null pointer as in C or Java, where it is
> a special value that can be assigned in a variable of any pointer
> type.
>
> Common Lisp does not have such a construct.  It has the NIL
> symbol, which is also the empty list and the false value; but it
> is not automatically included in other types.  For example, if
> you declare that a variable will always hold a STRING, then NIL
> is not a valid value for it.  If you want to allow NIL too,
> declare the type as (or string null), or just omit the
> declaration altogether.

Ah, yes.  Probably.

People should be wary of false cognates, both in real life and in
computer languages.

The vaguely more equivalent notion in CL is 'unbound', which is not
something you can assign, but is something that global variables can
start with if they have not been assigned.  No lexical variable ever
starts unbound, although some I believe can start with values of
implementation-defined nature (e.g., if you let-bind a variable
declared to be of a type that cannot hold NIL).
```
 0
pitman (1396)
12/13/2003 3:43:47 PM
```Kent M Pitman wrote:

>   No lexical variable ever
> starts unbound, although some I believe can start with values of
> implementation-defined nature (e.g., if you let-bind a variable
> declared to be of a type that cannot hold NIL).

According to the definition of LET and LET*, if you omit the initform
the variable is initialized to NIL.  A program that declares the
variable to be some type that does not contain NIL would be nonconforming.

Paul

```
 0
dietz (398)
12/13/2003 3:46:08 PM
```"Paul F. Dietz" <dietz@dls.net> writes:

> Kent M Pitman wrote:
>
> >   No lexical variable ever
> > starts unbound, although some I believe can start with values of
> > implementation-defined nature (e.g., if you let-bind a variable
> > declared to be of a type that cannot hold NIL).
>
> According to the definition of LET and LET*, if you omit the initform
> the variable is initialized to NIL.  A program that declares the
> variable to be some type that does not contain NIL would be nonconforming.

I suppose I should grub around and see if I agree that this is the
only relevant case.  I know we hassled over it enough that I don't
recall the outcome.  That's why I said "I believe", to flag that I
was not sure.

```
 0
pitman (1396)
12/13/2003 5:08:15 PM
 Reply:

Similar Artilces:

#if 0?0?0:0:0
The following 4-lines source fragment test.c (fourth line empty) #if 0?0?0:0:0 #endif int main(void){return 0?0?0:0:0;} cause: test.c(1) : fatal error C1017: invalid integer constant expression when compiled by cl.exe aka "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86". On the other hand this compile and runs fine. #if 0?(0?0:0):0 #endif int main(void){return 0?0?0:0:0;} Did I hit a but it this compiler's preprocessor? Francois Grieu On 3/30/2010 12:47 PM, Francois Grieu wrote: > The following 4-lines source fr...

0,0 not 0,0
hi all, i have 2 drawings - ground floor and first floor. when i do an ID on a point on the grid i get the same readings for both drawings however, when i xref one into the other or both into a new drawing they come in in different locations. i've checked they're both using world UCS and the same units. any ideas? i thought with autocad 0,0 was always 0,0? cheers rob "Coro, Rob" <RE-Coro@bdp.co.uk> schrieb: >hi all, > >i have 2 drawings - ground floor and first floor. when i do an ID on a >point on the grid i get the same readings for bo...

IP 0.0.0.0/0
Hi Any useful link that explains this IP address range in details, please? Thanks in advance! The Dude In article <Jp6Hg.458762\$IK3.24918@pd7tw1no>, The Dude <The Dude@thedu.de> wrote: >Any useful link that explains this IP address range in details, please? Urrr -- 0.0.0.0/0 is the *entire* IPv4 address range, and 0.0.0.0/32 is just the single IPv4 address 0.0.0.0. For any given network, the lowest address in the network is reserved. Historically, the lowest address was one of the two allowed choices for the broadcast address; later, the broadcast a...

0.0**0 = ?
I'm wondering if 0.0**0 (as opposed to 0.0**0.0) has the value 1 as per fortran standard or if this is left to the compiler vendors (different vendors do different things, unhappily). Thanks, Joost Joost VandeVondele wrote: > I'm wondering if 0.0**0 (as opposed to 0.0**0.0) has the value 1 as > per fortran standard or if this is left to the compiler vendors > (different vendors do different things, unhappily). > > Thanks, > > Joost Surely, 0.0**0.0 is mathematically undefined? Therefore, I wouldn't expect the standard to make any pronouncement about the ...

Simplifying {0,0,0}.X.{0,0,0}
Hello, In brief: Is there a way that I can specify that "X" is a matrix and will resolve to zero when dot multiplied with a vector of zeros? I'm constructing a swathe of expressions that contain things like (when expanded): {0,0,0}.X.{0,0,0}, where X is an arbitrary (well, positive definite) square matrix of obvious size, and I'd like to be able to have mathematica simplify that for me without much intervention. My only option at the moment is to manually perform the replacements {{0, 0, 0}.X._ -> 0, _.X.{0, 0, 0} -> 0} (the left and right vectors won...

"some\0\0\0\0\0\0"
can i use such form of adding zeros to the strings/literals to 'pad' them with zeros ? or this is not guwranteed to work? need that for assuring that strings for example arepadded to some amount of bytes thus using fast compare which only checks some amount of data and do not bother for checking ends, etc 9you know what i mean) On Thu, 13 Aug 2015 12:30:19 -0700, fir saw fit to publish the following: > can i use such form of adding zeros to the strings/literals to 'pad' > them with zeros ? Yes you can. (I feel SOOO presidential right now) > or this is n...

what is the significance of 0.0.0.0
is this the default gateway of whole internet. or is this the default gateway of a whole class A ip addresses. or is this a network address of a particular sub-net. please explain it pragmatically with regards novice wrote: > is this the default gateway of whole internet. > or is this the default gateway of a whole class A ip addresses. > > or is this a network address of a particular sub-net. > please explain it pragmatically > with regards Written that way, it's nothing more than an IP address. On 10/04/2010 02:53 PM, novice wrote: > is this the default gatewa...

0:0:0:0:phone
Under kerio Admin screen,local Address I get: 0:0:0:0:phone where "phone" is the local port number. What the hell is that supposed to mean? MikeStevens.invalid@spamtrap.org wrote: > Under kerio Admin screen,local Address I get: 0:0:0:0:phone > > where "phone" is the local port number. What the hell is that supposed to > mean? That's illegal -- there should be nothing coming from 0.0.0.0 at all, on ANY port. Block that IP outright. -- Cinemuck, n.: The combination of popcorn, soda, and melted chocolate which covers the floors of movie thea...

*.so , *.la , *.a , *.so.0.0.0 , *.so.1.0.0 ...
I noticed so many extensions in the /usr/lib directory of my Linux system. .so stands for shared object but also there are other extensions can anyone please explain or atleast give pointers to where I can find information about these extensions in details. regards, Onkar onkar <onkar.n.m@gmail.com> wrote: > I noticed so many extensions in the /usr/lib directory of my Linux > system. .so stands for shared object but also there are other > extensions can anyone please explain or atleast give pointers to where > I can find information about these extensions in detail...

How to interpolate a [0 0 0 1 0 0 ...0 1 0 0 0 ...0 0] vector please help
dear friends, i have t vector; t=linspace(0,.00007,76); k vector is [0 0 0 1......1 0 0 ..], its like all zeros except two 1`s, on a different time instants. when i apply this command ; k=interp1(tau,k,t); tau is also the same as t. one question is that,do we need to interpolate the vector k from one time vector to another of the same length? as here length(t)=length(tau). second question is that when i apply this command, the vector k is returned as a single entry???? please help me on this one. thanks "salman " <salmanabdullah9@gmail.com> wrote in message <iujd42\$s...

Re: Simplifying {0,0,0}.X.{0,0,0}
Hi Jens, and others, On Mar 7, 6:10 pm, Jens-Peer Kuska <k...@informatik.uni-leipzig.de> wrote: > Hi, > > X /: Dot[X, a : {0 ..}] := a > > will help. Ah! TagSet, I get it; very useful. Mathematica is rather amazing. Its syntax is more flexible than I can imagine, coming from another system & TeX. Thanks all, Will ...

Why does python break IEEE 754 for 1.0/0.0 and 0.0/0.0?
I've read over and over that Python leaves floating point issues up to the underlying platform. This seems to be largely true, but not always. My underlying platform (IA32 Linux) correctly handles 1.0/0.0 and 0.0/0.0 according to the IEEE 754 standard, but Python goes out of its way to do the wrong thing. 1/0 is defined by the standard as +Inf and 0/0 is NaN. That's what my platform does for programs written in C. Python apparently checks for division by zero and throws and exception rather than returning the correct value calculated by the underlying platform. Is there any way...

ip 0.0.0.0 is attempting to ....
NIS2004 told me a remote computer at ip 0.0.0.0 is trying to access my computer, and asked if it should allow it. I'm thinking that is probably just the dsl modem and I should allow it. Can anyone confirm or instruct? "Adam Russell" <REMOVE_THIS_adamrussell@sbcglobal.net> wrote in message news:<bro2a6\$5lbqu\$1@ID-122512.news.uni-berlin.de>... > NIS2004 told me a remote computer at ip 0.0.0.0 is trying to access my > computer, and asked if it should allow it. I'm thinking that is probably > just the dsl modem and I should allow it. Can anyone confirm...

dhclient leasing 0.0.0.0
hi, OS: FreeBSD 4.9-Release im starting the dhclient at bootup from the rc.conf file. in the process list it shows as: /sbin/dhclient -pf /var/run/dhclient.ed1.pid ed1 the ipaddress leased shows: # ifconfig -a .... faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500 ed1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255 ether 00:02:dd:1f:10:89 after killing the dhclient process and starting it again with: # dhclient everything is fine and i get a working ipaddress. my dhcp confi...

Web resources about - (= 0/0 0/0) - comp.lang.lisp

Resources last updated: 2/9/2016 12:33:17 PM