Solved

Q for rosefire:  Neg 0s in IEEE 754

Posted on 1998-12-15
7
318 Views
Last Modified: 2012-05-04
Hi rosefire;

I gave the points for the last question to ozo, but I am interseted in what you brought up.  Could you give me more info on what types of problems an application would have with a negative zero representation?

Thanks,

Matt
0
Comment
Question by:MatthewL
  • 3
  • 3
7 Comments
 
LVL 3

Accepted Solution

by:
rosefire earned 50 total points
ID: 1013697
Floating-point arithmetic on digital computers is inexact. The 23 bits plus the hidden bit of mantissa in a 32-bit floating-point number equates to roughly  7 significant digits. As I am sure you know, floating-point systems differ from real numbers in that they have gaps between each number. If a number is not exactly representable, then it must be approximated by one of the nearest representable values.  This can be positive zero, or it can be negative zero.

Because the same number of bits are used to represent all normalized numbers, the smaller the exponent, the greater the proximity  of representable numbers. For example, there are approximately 8.3 million single-precision numbers between 1.0 and 2.0, while there are only about 8k between 1023.0 and 1024.0.

On any computer, mathematically equivalent expressions can produce different results. In this example, Z and Z1 will typically have different values because (1/Y) or 1/7 is not exactly representable in binary floating-point:

REAL X, Y, Y1, Z, Z1
DATA X/77777/, Y/7/
Y1 = 1 / Y
Z = X / Y
Z1 = X * Y1
IF (Z .NE. Z1) PRINT *, 'Not equal!'
END

A programmer has to keep the inexact nature of the floating point number in mind when writing a program where rounding can take you to either to a negative or positive zero when rounding.  Unexpected cases can arise.

The vast majority of problems with positive and negative zero representations are ones that are a result of programmers failure to handle the negative zero rounding case properly.  Programs will work and seem bug free but make mistakes with corner cases that arise infrequently.    Intel got burned on such a rounding problem pretty good if you recall.

Hope that helps.  If you have any further questions, let me know.

RoseFire
0
 
LVL 84

Expert Comment

by:ozo
ID: 1013698
The problem of inexactness in floating point representations exists regardless of how many kinds of zero there are.
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013699
Once again thanks to you both.

So does this mean the potential problem would be with a JS or JL instruction incorrectly ( in our interpretation ) jumping?

Matt
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 3

Expert Comment

by:rosefire
ID: 1013700
I don't understand your last question.  I don't know the particulars of the problem with the long and short jump problem you refer to.

RoseFire
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013701
Hi rosefire;

I was just trying to think of where the problems would occur.  So I thought maybe on JS ( jump on sign) would jump on a negative 0 but not on a positive 0 and therefore create an inconsistency.  Is this a correct interpretation?

Matt
0
 
LVL 3

Expert Comment

by:rosefire
ID: 1013702
Actually, I don't know compilers well enough to answer that, but i would hope that a complier would know the difference between negative and positive zero.  Now, if you are an assembly language programmer, the outcome could be ambiguous but he hardware should ignore the sign bit in doing the compare if it is IEEE compliant.

Hope that helps.

RoseFire
0
 
LVL 1

Author Comment

by:MatthewL
ID: 1013703
Thanks,


Matt
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We recently endured a series of broadcast storms that caused our ISP to shut us down for brief periods of time. After going through a multitude of tests, we determined that the issue was related to Intel NIC drivers on some new HP desktop computers …
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question