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. Double to int?

Double to int?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • H Offline
    H Offline
    Hoornet93
    wrote on last edited by
    #1

    How can I ROUND double to int, please? Love is the law, love under will.

    M M 2 Replies Last reply
    0
    • H Hoornet93

      How can I ROUND double to int, please? Love is the law, love under will.

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

      try floor(dValue + 0.5) for positive values

      1 Reply Last reply
      0
      • H Hoornet93

        How can I ROUND double to int, please? Love is the law, love under will.

        M Offline
        M Offline
        Marcello
        wrote on last edited by
        #3

        Hello, maybe it will be useful for you to know a little bit more about this: double val1 = floor( 2.3 + 0.5 ); double val2 = floor( -2.3 + 0.5 ); double val3 = ceil( 2.3 + 0.5 ); double val4 = ceil( -2.3 + 0.5 ); printf( "%f, %f, %f, %f\r\n", val1, val2, val3, val4 ); will give you: 2.000000, -2.000000, 3.000000, -1.000000 Cheers, Marcello

        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