Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FP Question

FP Question

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cmania
    wrote on last edited by
    #1

    Thnkx a lot for "floating point comparisions"............. Does this mean IEEE32/64 arent good enough to store FPs accurately AND wat when we use the same number to print on screen......i mean how is that FP printed accurately?

    Spread wat u Know!

    M 1 Reply Last reply
    0
    • C Cmania

      Thnkx a lot for "floating point comparisions"............. Does this mean IEEE32/64 arent good enough to store FPs accurately AND wat when we use the same number to print on screen......i mean how is that FP printed accurately?

      Spread wat u Know!

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      Read What Every Computer Scientist Should Know About Floating Point Arithmetic[^]. A binary floating-point number can only store numbers that are sums of powers of two. The digits to the right of the point are sums of negative powers of two. Just as 1/3 is not accurately representable in decimal (0.33333.... etc), 1/5 is not accurately representable in binary. The more operations you perform on a limited precision representation, the more representation error builds up. That's why it's rarely a good idea to directly compare two floating point numbers. I don't think there are any values representable in binary that are not representable in decimal, because two divides evenly into ten. However, when displaying a floating point result, it's common to only show some decimal places, displaying a rounded result. If you want decimal values, with a fixed decimal point, to be stored and computed accurately, you should use a scaled integer. This is not supplied by standard C++ so you'll have to find an implementation, e.g. here[^].

      Stability. What an interesting concept. -- Chris Maunder

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups