Solved

Q for rosefire:  Neg 0s in IEEE 754

Posted on 1998-12-15
7
316 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:rosefire
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks,


Matt
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Join & Write a Comment

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…
In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now