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. Algorithms
  4. Find .56 from 19.56

Find .56 from 19.56

Scheduled Pinned Locked Moved Algorithms
help
10 Posts 9 Posters 3 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.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

    E Z G C R 6 Replies Last reply
    0
    • V varshavmane

      Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      What language are you programming in?

      The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

      V J 2 Replies Last reply
      0
      • V varshavmane

        Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

        Z Offline
        Z Offline
        zqueezy
        wrote on last edited by
        #3

        in mathematical way I would say .56 = 19.56 - floor(19.56) or in c++ float rest = 19.56 - int(19.56); sufficient?

        1 Reply Last reply
        0
        • V varshavmane

          Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

          G Offline
          G Offline
          Giorgi Dalakishvili
          wrote on last edited by
          #4

          I think this should help you: http://en.wikipedia.org/wiki/Floor_function

          1 Reply Last reply
          0
          • E Expert Coming

            What language are you programming in?

            The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

            V Offline
            V Offline
            varshavmane
            wrote on last edited by
            #5

            Thanks for the help.I need a mathematical way I dont want to use programming language for this....

            C 1 Reply Last reply
            0
            • V varshavmane

              Thanks for the help.I need a mathematical way I dont want to use programming language for this....

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              By convention there is the [] operator, defined the following way

              = the integer part of x

              hence you can use

              x-[x]

              to extract the decimal part of x But, I know, it's just another way to say: 'take the decimal part of x' (BTW it is also a perfectly accetable function definition). :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

              1 Reply Last reply
              0
              • V varshavmane

                Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

                C Offline
                C Offline
                cmk
                wrote on last edited by
                #7

                For what it's worth, in C/C++ the function you want is modf. i.e. http://msdn2.microsoft.com/en-us/library/bk4c380c(VS.80).aspx[^]

                ...cmk Save the whales - collect the whole set

                1 Reply Last reply
                0
                • V varshavmane

                  Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

                  R Offline
                  R Offline
                  Rilhas
                  wrote on last edited by
                  #8

                  I think it is important for you to clarify what to do with negative numbers. What would you want to obtain with -19.56? -.56 or .44 (=-19.56-20.00)? The formula is usually simple for positive numbers because we all agree the integer part is the largest integer not greater than the given number, but for negative numbers we have to decide which reference to have (either 0 or -oo). Rilhas

                  1 Reply Last reply
                  0
                  • V varshavmane

                    Hi All, I need to find the value after decimal in mathematical way... Ex: I have a number 19.56 and my formula gives me .56 Please help me... Thanks in advance...

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    x=((x*100)%100)/100

                    1 Reply Last reply
                    0
                    • E Expert Coming

                      What language are you programming in?

                      The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

                      J Offline
                      J Offline
                      Jeffrey Walton
                      wrote on last edited by
                      #10

                      ExpertComing wrote:

                      The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.

                      LOL...

                      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