Register to reply

Why is the value zero not possible with computers?

by fisico30
Tags: computers
Share this thread:
fisico30
#1
Jan8-13, 04:20 PM
P: 374
Hello Forum,
any number that a computer deals with is just an approximation...in what sense?

Why is the number zero not possible? The number zero is often a very very very small number (10^-19) but never exactly zero. Why?

thanks,
fisico30
Phys.Org News Partner Science news on Phys.org
Scientists discover RNA modifications in some unexpected places
Scientists discover tropical tree microbiome in Panama
'Squid skin' metamaterials project yields vivid color display
Integral
#2
Jan8-13, 04:40 PM
Emeritus
Sci Advisor
PF Gold
Integral's Avatar
P: 7,334
I think the issue is with floating point numbers. They consist of a mantissa and exponent. While you can set the mantissa to zeros an exponent of zero sets the number equal to 1. So the only way to get near zero is to have a large negative exponent. That number format cannot precisely represent zero. I would be surprised if there are not ways to get around this.
trollcast
#3
Jan8-13, 04:53 PM
PF Gold
trollcast's Avatar
P: 291
I'm not 100% if this is what you're looking but it might help:

http://www.johndcook.com/blog/2010/0...e-signed-zero/

fisico30
#4
Jan8-13, 06:31 PM
P: 374
Why is the value zero not possible with computers?

thank you.
I was doing some matlab and looking for zeros but all I could find was very small values, no zeros. The function I was using was supposed to give some zeros but it didn't.

Fisico30
Mark44
#5
Jan8-13, 06:40 PM
Mentor
P: 21,397
Quote Quote by Integral View Post
I think the issue is with floating point numbers. They consist of a mantissa and exponent. While you can set the mantissa to zeros an exponent of zero sets the number equal to 1.
No, that's not right.

Conceptually, floating point numbers are {sign} {mantissa} X 2{exponent}. Per this wiki page (http://en.wikipedia.org/wiki/IEEE_754-1985), zero can be represented as either positive zero or negative zero, with sign being either 0 or 1, respectively, mantissa being zero for both, and exponent being zero for both.
Quote Quote by Integral View Post
So the only way to get near zero is to have a large negative exponent. That number format cannot precisely represent zero. I would be surprised if there are not ways to get around this.
Mark44
#6
Jan8-13, 06:41 PM
Mentor
P: 21,397
Quote Quote by fisico30 View Post
thank you.
I was doing some matlab and looking for zeros but all I could find was very small values, no zeros. The function I was using was supposed to give some zeros but it didn't.
This isn't a problem of the computer not being able to store zero (which it can), but of the software not being able to calculate precisely enough to find a value for which the function value was exactly zero.
Mark44
#7
Jan8-13, 06:44 PM
Mentor
P: 21,397
Quote Quote by fisico30 View Post
any number that a computer deals with is just an approximation...in what sense?
This is not true in general. Computers can store many integer values exactly. As already mentioned in this thread, the problem comes with how non-integer real numbers are stored.
Quote Quote by fisico30 View Post

Why is the number zero not possible? The number zero is often a very very very small number (10^-19) but never exactly zero. Why?
10^(-19) is NOT zero. It's pretty small, but it isn't zero.
SteamKing
#8
Jan8-13, 06:55 PM
Emeritus
Sci Advisor
HW Helper
Thanks
PF Gold
P: 6,723
IEEE 754 specifies signed zeroes in its floating point standard.
+0 = -0 = 0, so it is possible for zero to be represented on a computer.

How else would we get "Error: Divide by zero" messages?
phinds
#9
Jan8-13, 06:59 PM
PF Gold
phinds's Avatar
P: 6,486
Quote Quote by fisico30 View Post
Hello Forum,
any number that a computer deals with is just an approximation...in what sense?

Why is the number zero not possible? The number zero is often a very very very small number (10^-19) but never exactly zero. Why?

thanks,
fisico30
Mark has pretty much covered it except for pointing out that SOME floating point numbers are represented exactly, NOT approximately as you seem to think, while some ARE represented as approximations.

All integers are represented exactly UP TO THE LIMIT of the computers ability to express integers. For an 8-bit computer (the VERY early kind) that was 256. For a 16-bit computer, that's 65536, and so forth.

Perhaps it will help you understand the "approximation" business if you think of a decimal computer that has the ability to represent 10 significant digits.

How would that computer represent the answer when doing the division 1/3 ? Well, it would be .3333333333 which is only an approximation because of the necessary rounding. Binary computer have the same problem, just in binary.
rcgldr
#10
Jan8-13, 11:22 PM
HW Helper
P: 7,170
Quote Quote by phinds View Post
How would that computer represent the answer when doing the division 1/3?
One option, available on some calculators, and in some libraries for computers, is fractional math, where numbers are are stored as fractions with integer numerators and denomiators. I'm not sure how practical this is versus being a novelty feature found on some calculators.
phinds
#11
Jan9-13, 12:21 AM
PF Gold
phinds's Avatar
P: 6,486
Quote Quote by rcgldr View Post
One option, available on some calculators, and in some libraries for computers, is fractional math, where numbers are are stored as fractions with integer numerators and denomiators. I'm not sure how practical this is versus being a novelty feature found on some calculators.
Seems pretty likely that the OP is talking about normal computers, so this is not relevant.
NemoReally
#12
Jan9-13, 05:08 AM
P: 194
Quote Quote by phinds View Post
Seems pretty likely that the OP is talking about normal computers, so this is not relevant.
It is relevant for 'normal' computers as it is application dependent. Standard Matlab (which the OP uses) uses the IEEE format for calculation, which will result in the observed 'non-zero' zeros. However, the Matlab Symbolic Toolbox uses a bignum format and may well (depending upon the type of the number) store numbers as rationals.

Mathcad's symbolic processor works in a similar fashion as does Mathematica and at least a few other symbolic applications.
lpetrich
#13
Jan9-13, 05:14 AM
P: 533
Seems to me that this is a roundoff-error issue. I've seen it a lot myself.

The only rational numbers that can be represented with a finite number of trailing digits in some number-base system are those whose denominators are nonnegative-integer powers of the base. Otherwise one gets an infinitely-repeating finite sequence of digits after some finite number of initial digits. Irrational numbers are even worse. They cannot be represented with a finite number of trailing digits in *any* base.

It's possible for computers to work with integers and floating-point numbers with arbitrarily high numbers of digits, limited only by the available memory. One has to work with arrays of digits, but it's feasible. It's also possible for computers to work with exact rational numbers as pairs of integers. It's easy to write functions that implement the rules for manipulating fractions.

You can find all this in The GNU MP Bignum Library and in various computer-algebra packages.

I implemented rational numbers myself for the C++ version of my semisimple-Lie-algebra software, because I wanted something faster than GMP. I did it as a template class, with a parameter: the type of integer.
phinds
#14
Jan9-13, 05:29 AM
PF Gold
phinds's Avatar
P: 6,486
Quote Quote by NemoReally View Post
It is relevant for 'normal' computers as it is application dependent. Standard Matlab (which the OP uses) uses the IEEE format for calculation, which will result in the observed 'non-zero' zeros. However, the Matlab Symbolic Toolbox uses a bignum format and may well (depending upon the type of the number) store numbers as rationals.

Mathcad's symbolic processor works in a similar fashion as does Mathematica and at least a few other symbolic applications.
Fair enough, but I was talking about the computer at the hardware level, as I believe the OP was, not applications.
phinds
#15
Jan9-13, 05:30 AM
PF Gold
phinds's Avatar
P: 6,486
Quote Quote by lpetrich View Post
Seems to me that this is a roundoff-error issue ...
Yes, exactly.
jim mcnamara
#16
Jan9-13, 06:08 AM
Sci Advisor
PF Gold
P: 1,386
The Goldberg article is one of the "standard" references for programmers who want to understand floating point (non-integer arithmetic operations on IEEE conforming platforms):

http://docs.oracle.com/cd/E19957-01/..._goldberg.html

This article is about practical applications - comparison of floats:

http://www.cygnus-software.com/paper...ringfloats.htm


Register to reply

Related Discussions
The jet age of computers General Discussion 39
Can computers only do what we tell them to? General Discussion 17
Old Computers Computing & Technology 17
IQ with Computers Social Sciences 7
Do you think computers cause... Computing & Technology 2