Thread: Help using factorial function...

  1. #16
    Registered User
    Join Date
    Sep 2007
    Posts
    48
    finally, hahaha, yea i guess that was the prob, i wasn't allocating enough memory for the variables so it was spitting back weird numbers

    thanks for all the help guys

  2. #17
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Note that matsp's explanation of how floating point types are represented are not guaranteed by the standard, those are just common implementations on current architectures.

    The standard basically just says that double is at least as precise as float, and long double is at least as precise as double.

  3. #18
    Registered User
    Join Date
    Sep 2007
    Posts
    48
    if basically each are only as precise as the other, why have three different types in the first place?

  4. #19
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    at least as precise

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by wco5002 View Post
    if basically each are only as precise as the other, why have three different types in the first place?
    The wording of the standard says so because there are some machines that only have ONE type of floating point number, and other machines with two, or three or four different floating point formats. For the standard to work on ALL of those, it gives some flexibility to the implementor of the compiler to choose different forms that are good for the architecture you are implementing on. For example, some machine may only have a "double" type floating point number. So even if you choose "float", you get the same thing as "double". On another machine, there are "single" and "double" precision floating point. On a third machine there's single, double and extended floating point. What the standard guarantees is that the precision of a double is at least as good as float - so if you choose double, you get a "good precision", whilst "float" may not be as precise.

    It's actually the same for integers. The only guarantee about "long" for example, is that it's not SHORTER than an "int" - and that "short" isn't longer than "int". But there's nothing saying that they all can't be the same size on a machine where that's "the best solution".

    --
    Mats

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM