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 precision

float precision

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
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.
  • O Offline
    O Offline
    OO P
    wrote on last edited by
    #1

    hello , how can i set float precisoin in mfc ? I get like this format ex. 1.500000 what i want is to print just 3 number after the decimal point . my code : CString temp; float price =20.570; sprintf(temp,"%f",price); i got this 20.570000 how can i make the decimal point print just 3 number like this 20.570 and thank you .

    A 1 Reply Last reply
    0
    • O OO P

      hello , how can i set float precisoin in mfc ? I get like this format ex. 1.500000 what i want is to print just 3 number after the decimal point . my code : CString temp; float price =20.570; sprintf(temp,"%f",price); i got this 20.570000 how can i make the decimal point print just 3 number like this 20.570 and thank you .

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      double d = 1.5000000;
      CString str;
      str.Format("%.3f");

      or

      printf("%.3f", d);

      Sonork 100.41263:Anthony_Yio

      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