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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Controlling iostream display behaviour.

Controlling iostream display behaviour.

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
4 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
    oRion
    wrote on last edited by
    #1

    I am trying to control how the scientific notation in VC++ display when I call it. It seems that iostream have a default behaviour how it should look like. I can't seems to be able to control it. For example, the scientific notation of the exponent have to be 3 digits long. There could only be 1.23E+003, where I wanted it to display 12.3E+002 , I can't seems to do that. Is there a library available that allows this to be implemented easily, or I have to write my own stream?I hope that is a easy way to do it. Any suggest from anyone? Just Danny

    S 1 Reply Last reply
    0
    • O oRion

      I am trying to control how the scientific notation in VC++ display when I call it. It seems that iostream have a default behaviour how it should look like. I can't seems to be able to control it. For example, the scientific notation of the exponent have to be 3 digits long. There could only be 1.23E+003, where I wanted it to display 12.3E+002 , I can't seems to do that. Is there a library available that allows this to be implemented easily, or I have to write my own stream?I hope that is a easy way to do it. Any suggest from anyone? Just Danny

      S Offline
      S Offline
      Sijin
      wrote on last edited by
      #2

      Have you tried using the iostream format flags? Don't remember excatly but you could use the flags to format the output. Eg. cout<May the Source be with you Sonork ID 100.9997 sijinjoseph

      O 1 Reply Last reply
      0
      • S Sijin

        Have you tried using the iostream format flags? Don't remember excatly but you could use the flags to format the output. Eg. cout<May the Source be with you Sonork ID 100.9997 sijinjoseph

        O Offline
        O Offline
        oRion
        wrote on last edited by
        #3

        Thanks for the reply. I can set it using setprecision() and setw(), but I can't change it's behaviour. I mean I like my scientific notation to have 2 digits before the decimal points not the default( ie. 1.23E+010) , I was hoping to get 12.34E+009 . Hope u can understand what I mean.I am converting a code from FORTRAN which allows this to happen. X|

        S 1 Reply Last reply
        0
        • O oRion

          Thanks for the reply. I can set it using setprecision() and setw(), but I can't change it's behaviour. I mean I like my scientific notation to have 2 digits before the decimal points not the default( ie. 1.23E+010) , I was hoping to get 12.34E+009 . Hope u can understand what I mean.I am converting a code from FORTRAN which allows this to happen. X|

          S Offline
          S Offline
          Sijin
          wrote on last edited by
          #4

          Do you have to use cout?? You could do what you want with printf() May the Source be with you Sonork ID 100.9997 sijinjoseph

          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