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. Float/Double rounding off

Float/Double rounding off

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.
  • I Offline
    I Offline
    Imtiaz Murtaza
    wrote on last edited by
    #1

    Dear Friends, I want to round the float/doublevalue upto two decimal places and display in edit control. How can i do so. Here is the scenario: I got an edit control on which a double variable is associated. I assign some value to this variable and call UpdateData(FALSE). As such the edit control gets populated with the value, but value is appearing of the form 67.24678945. I want to get this value of the form 67.25 i.e rounded upto two decimal places. Imtiaz

    M 1 Reply Last reply
    0
    • I Imtiaz Murtaza

      Dear Friends, I want to round the float/doublevalue upto two decimal places and display in edit control. How can i do so. Here is the scenario: I got an edit control on which a double variable is associated. I assign some value to this variable and call UpdateData(FALSE). As such the edit control gets populated with the value, but value is appearing of the form 67.24678945. I want to get this value of the form 67.25 i.e rounded upto two decimal places. Imtiaz

      M Offline
      M Offline
      mahade1
      wrote on last edited by
      #2

      Hi, Instead of associating a double variable with the edit control, use a CString variable. Before calling UpdateData(FALSE) use something like this strFloat.Format("%.2f", fFloatVal); where fFloatVal contains ur decimal value. Regards, Mahadevan

      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