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. How to get the actual value?

How to get the actual value?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++helptutorial
9 Posts 4 Posters 2 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.
  • S Offline
    S Offline
    ShiningStarPxx
    wrote on last edited by
    #1

    Hi I am a student.When I do my homework,i encounter a problem.I can not get the actual value in VisualC++. The question is how to get 95.123 raised by 12. Maybe I haven't explained my mean.Sorry about my poor English! Thanx first! -- modified at 1:49 Thursday 27th October, 2005

    C D 2 Replies Last reply
    0
    • S ShiningStarPxx

      Hi I am a student.When I do my homework,i encounter a problem.I can not get the actual value in VisualC++. The question is how to get 95.123 raised by 12. Maybe I haven't explained my mean.Sorry about my poor English! Thanx first! -- modified at 1:49 Thursday 27th October, 2005

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      :doh: :confused: What are you speaking about ?? What means " 95.123 's 12th power " ?? And what are you trying to do exactly and what is the exact problem encoutered ? Try to be more specific.

      S 1 Reply Last reply
      0
      • S ShiningStarPxx

        Hi I am a student.When I do my homework,i encounter a problem.I can not get the actual value in VisualC++. The question is how to get 95.123 raised by 12. Maybe I haven't explained my mean.Sorry about my poor English! Thanx first! -- modified at 1:49 Thursday 27th October, 2005

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        ShiningStarPxx wrote:

        The question is how to get 95.123 's 12th power.

        Do you mean 95.12312 instead? Even using an unsigned long double, you'd get something like 5.4881562051773182e+023. You might could get a bit more precision by using the DECIMAL data type.


        "Take only what you need and leave the land as you found it." - Native American Proverb

        S 1 Reply Last reply
        0
        • D David Crow

          ShiningStarPxx wrote:

          The question is how to get 95.123 's 12th power.

          Do you mean 95.12312 instead? Even using an unsigned long double, you'd get something like 5.4881562051773182e+023. You might could get a bit more precision by using the DECIMAL data type.


          "Take only what you need and leave the land as you found it." - Native American Proverb

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

          Thank you first! But i can not catch your means.Would you like to explain it with a sample code.

          A D 2 Replies Last reply
          0
          • C Cedric Moonen

            :doh: :confused: What are you speaking about ?? What means " 95.123 's 12th power " ?? And what are you trying to do exactly and what is the exact problem encoutered ? Try to be more specific.

            S Offline
            S Offline
            ShiningStarPxx
            wrote on last edited by
            #5

            The question is how to get 95.123 raised by 12. Maybe I haven't explained my means.Sorry about my poor English!

            C 1 Reply Last reply
            0
            • S ShiningStarPxx

              The question is how to get 95.123 raised by 12. Maybe I haven't explained my means.Sorry about my poor English!

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              You can use the double pow(double,double); for that purpose. Don't forget to include math.h at the top of your file ;).

              1 Reply Last reply
              0
              • S ShiningStarPxx

                Thank you first! But i can not catch your means.Would you like to explain it with a sample code.

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                #include #include void main( void ) { double x = 2.0, y = 3.0, z; z = pow( x, y ); printf( "%.1f to the power of %.1f is %.1f\n", x, y, z ); } Output 2.0 to the power of 3.0 is 8.0

                A 1 Reply Last reply
                0
                • A Anonymous

                  #include #include void main( void ) { double x = 2.0, y = 3.0, z; z = pow( x, y ); printf( "%.1f to the power of %.1f is %.1f\n", x, y, z ); } Output 2.0 to the power of 3.0 is 8.0

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #8

                  Oops sorry, the <'s and >'s got removed, the #include's should be #include <math.h> #include <stdio.h>

                  1 Reply Last reply
                  0
                  • S ShiningStarPxx

                    Thank you first! But i can not catch your means.Would you like to explain it with a sample code.

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    On paper, 95.12312 is 548815620517731830194541.89902534. However, that number is too big to fit in any type, including an unsigned long double. It would only give you something like 5.4881562051773182e+023 (which equates to 548815620517731820000000.0). Notice the loss of precision. A DECIMAL type may get you a bit more precision.


                    "Take only what you need and leave the land as you found it." - Native American Proverb

                    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