incorrect initialisation

This is a discussion on incorrect initialisation within the C Programming forums, part of the General Programming Boards category; Hi, I've got an array of type float and when I initialise a number eg 9.04, it stores it as ...

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

    incorrect initialisation

    Hi,
    I've got an array of type float and when I initialise a number eg 9.04, it stores it as 9.03999996. Numbers are not exactly right, so why does this happen?
    I'm using linux, gcc 3.4.6, and ddd if this has anything to do with it...

    Cheers
    Spiros

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    55
    cheers!, the section on compairing numbers was a real eye openerr!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hash Table outputting incorrect number
    By Paul Skinner in forum C Programming
    Replies: 4
    Last Post: 11-20-2008, 05:19 AM
  2. Static member (map) / constructor initialisation problem
    By drrngrvy in forum C++ Programming
    Replies: 9
    Last Post: 12-28-2005, 11:03 AM
  3. It is not incorrect to use void main
    By momo20016 in forum A Brief History of Cprogramming.com
    Replies: 41
    Last Post: 12-22-2002, 09:17 AM
  4. Replies: 3
    Last Post: 07-24-2002, 08:46 AM
  5. 'The parameter is incorrect' - LoadImage
    By DarkAvenger in forum Windows Programming
    Replies: 1
    Last Post: 04-12-2002, 02:53 PM

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