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. Other Discussions
  3. Clever Code
  4. Just found one now

Just found one now

Scheduled Pinned Locked Moved Clever Code
helpperformancequestion
3 Posts 2 Posters 11 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.
  • E Offline
    E Offline
    ed welch
    wrote on last edited by
    #1

    int speed = thrust*10/mass; int range = (propellant*speed)/propConsume; do you see it? No, neither did I. Its the old, old rounding error again. This is the fix: int speed = thrust*10/mass; int range = (propellant*thrust*10)/(propConsume*mass);

    Steve EcholsS 1 Reply Last reply
    0
    • E ed welch

      int speed = thrust*10/mass; int range = (propellant*speed)/propConsume; do you see it? No, neither did I. Its the old, old rounding error again. This is the fix: int speed = thrust*10/mass; int range = (propellant*thrust*10)/(propConsume*mass);

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      Why not use floats or doubles instead of ints, and then truncate them to ints if needed? (I've encountered this problem many times also)


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      E 1 Reply Last reply
      0
      • Steve EcholsS Steve Echols

        Why not use floats or doubles instead of ints, and then truncate them to ints if needed? (I've encountered this problem many times also)


        - S 50 cups of coffee and you know it's on!

        E Offline
        E Offline
        ed welch
        wrote on last edited by
        #3

        Unfortunately I don't have the luxury of floats on the platform that I'm developing (mobile phone)

        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