what is excess in floating point format

This is a discussion on what is excess in floating point format within the C++ Programming forums, part of the General Programming Boards category; In a floating point format, why is an "excess" used?...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    2

    what is excess in floating point format

    In a floating point format, why is an "excess" used?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    When there's too much?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Do it yourself:
    Code:
    #include<stdio.h>
    
    int main(){
    	const int lfloat=0x7f7fffff;//max positive float in hex, 8 bit for expoent
    	const unsigned __int64 ldouble=0x7fefffffffffffff;//max positive double in hex, 11 bit for expoent
    
    	const float FMAX = *(const float*)&lfloat;
    	const double DMAX = *(const double*)&ldouble;
    
    	printf("FLOAT MAX: %f\nDOUBLE MAX: %lf\n",FMAX,DMAX);
    	return 0;
    }
    /******************
    
    OUTPUT
    FLOAT MAX: 340282346638528860000000000000000000000.000000
    DOUBLE MAX: 17976931348623157000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000000000000000000000000
    0.000000
    *******************/
    1# Me thinks C++ currently doesn't suport by the standard 64bits ints
    2# __int64 is Microsofts compiler specific keyword. Use long long int for gcc. For Borland... I don't know.
    3# Raw C and pointer casting, anyone??
    4# Explicit hex values CANNOT be assigned to floating point numbers, so I used ints as auxiliaries
    5# To understand the hex values I assigned read this article from ieee about floating point number arithmetic.
    6# When all bits from the expoent are set, the number represents then not the number it suposed to be, but "NotANumber" or "Infinity". Overflow, division by zero, who knows?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  2. checking for floating point number
    By ssharish2005 in forum C Programming
    Replies: 6
    Last Post: 10-18-2005, 08:14 PM
  3. Understanding floating point
    By Eibro in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 05-11-2003, 03:58 PM
  4. Floating point faster than fixed-point
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-08-2001, 10:34 PM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21