Float Data Type Ranges

This is a discussion on Float Data Type Ranges within the C Programming forums, part of the General Programming Boards category; First of all I want to show my source: Data Type Ranges (C++) I am trying to figure out ranges. ...

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    93

    Float Data Type Ranges

    First of all I want to show my source:

    Data Type Ranges (C++)

    I am trying to figure out ranges.

    A float's model

    ((-1)^a)*b*2^c

    For a float:

    1 bit for sign (a)
    8 bits for bias (b)
    23 bits for mantissa (c)

    The range for the bias: [-127,128]

    The maximum point for the term has c

    Min:2^-127 ~= -5.877e-39
    Max:2^128 ~= 3.4e38

    For term b:

    The mantissa is that:

    1+b1*2^-1+b2*2^-2+...+b8*2^-8
    bmax== 2^1-2^-8~=2

    Then isn't the range of the float that one?

    [-2*3,4e38,2*3,4e38]

    1. It seems like they have ignored the value of 128 for the bias. Are they right?
    2. It seems they have also ignored the negative values. Cannot we use negative floats? It seems I can.
    Last edited by GokhanK; 02-25-2011 at 08:27 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    The very ends of the exponent are reserved for things like NaN's and infinities.
    Does this help?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By bennywhere in forum C Programming
    Replies: 16
    Last Post: 10-20-2009, 09:00 PM
  2. Model Rocket Altitude predictor...
    By kalor_alros in forum C++ Programming
    Replies: 11
    Last Post: 09-04-2009, 12:27 AM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  5. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM

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