Convert decimal to percentage value

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3















How can I convert a given decimal into the respective percentage value with a certain amount of positions q after the comma? The percentage should be rounded with respect to q+1.



For example, I am looking for something like




percentage[position after the comma]given decimal




that produces:



percentage[positions-after-comma = 2]0.12123456: 12.12% 
percentage[positions-after-comma = 4]0.12123456: 12.1235%
percentage[positions-after-comma = 4]2.12123456: 212.1235%
percentage[positions-after-comma = 1]0.6789: 67.9%
percentage[positions-after-comma = 5]0.6789: 67.89000%









share|improve this question




























    3















    How can I convert a given decimal into the respective percentage value with a certain amount of positions q after the comma? The percentage should be rounded with respect to q+1.



    For example, I am looking for something like




    percentage[position after the comma]given decimal




    that produces:



    percentage[positions-after-comma = 2]0.12123456: 12.12% 
    percentage[positions-after-comma = 4]0.12123456: 12.1235%
    percentage[positions-after-comma = 4]2.12123456: 212.1235%
    percentage[positions-after-comma = 1]0.6789: 67.9%
    percentage[positions-after-comma = 5]0.6789: 67.89000%









    share|improve this question


























      3












      3








      3








      How can I convert a given decimal into the respective percentage value with a certain amount of positions q after the comma? The percentage should be rounded with respect to q+1.



      For example, I am looking for something like




      percentage[position after the comma]given decimal




      that produces:



      percentage[positions-after-comma = 2]0.12123456: 12.12% 
      percentage[positions-after-comma = 4]0.12123456: 12.1235%
      percentage[positions-after-comma = 4]2.12123456: 212.1235%
      percentage[positions-after-comma = 1]0.6789: 67.9%
      percentage[positions-after-comma = 5]0.6789: 67.89000%









      share|improve this question
















      How can I convert a given decimal into the respective percentage value with a certain amount of positions q after the comma? The percentage should be rounded with respect to q+1.



      For example, I am looking for something like




      percentage[position after the comma]given decimal




      that produces:



      percentage[positions-after-comma = 2]0.12123456: 12.12% 
      percentage[positions-after-comma = 4]0.12123456: 12.1235%
      percentage[positions-after-comma = 4]2.12123456: 212.1235%
      percentage[positions-after-comma = 1]0.6789: 67.9%
      percentage[positions-after-comma = 5]0.6789: 67.89000%






      decimal-number percentage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 4 at 16:47







      BJPrim

















      asked Jan 4 at 16:31









      BJPrimBJPrim

      476




      476




















          2 Answers
          2






          active

          oldest

          votes


















          5














          You can use the siunitx package:



          documentclassarticle

          usepackagesiunitx

          newcommandpercentage[2][round-precision = 2]% default precision: 2
          SI[round-mode = places,
          scientific-notation = fixed, fixed-exponent = 0,
          output-decimal-marker=., #1]#2e2percent%


          begindocument

          percentage0.123456 % -> 12.35 %
          percentage[round-precision = 3]0.123456 % -> 12.345 %

          enddocument





          share|improve this answer
































            4














            Your values looks wrong. But beside this:



            documentclassarticle
            usepackagexfp,xparse
            ExplSyntaxOn
            int_new:Nl_bjprim_round_int
            keys_define:nn bjprim

            positions-after-comma .int_set:N = l_bjprim_round_int


            NewDocumentCommandpercentage O m

            keys_set:nn bjprimpositions-after-comma=2,#1
            fpevalround(#2*100,l_bjprim_round_int)%

            ExplSyntaxOff
            begindocument


            percentage[positions-after-comma = 2]0.123456: 12.12%

            percentage[positions-after-comma = 4]0.123456: 12.1235%

            percentage[positions-after-comma = 4]2.123456: 212.1235%

            percentage[positions-after-comma = 1]0.6789: 67.9%

            percentage[positions-after-comma = 5]0.6789: 67.89000%

            enddocument


            If you really want to fill up with zeros you could round with siunitx:



            documentclassarticle
            usepackagexfp,xparse,siunitx
            ExplSyntaxOn
            int_new:Nl_bjprim_round_int
            keys_define:nn bjprim

            positions-after-comma .int_set:N = l_bjprim_round_int


            NewDocumentCommandpercentage O m

            keys_set:nn bjprimpositions-after-comma=2,#1
            num[round-mode = places,round-precision=l_bjprim_round_int]fpeval#2*100%

            ExplSyntaxOff
            begindocument


            percentage[positions-after-comma = 2]0.123456: 12.12%

            percentage[positions-after-comma = 4]0.123456: 12.1235%

            percentage[positions-after-comma = 4]2.123456: 212.1235%

            percentage[positions-after-comma = 1]0.6789: 67.9%

            percentage[positions-after-comma = 5]0.6789: 67.89000%

            enddocument


            enter image description here






            share|improve this answer

























            • This way the optional argument is actually mandatory.

              – egreg
              Jan 4 at 16:59











            • @egreg thanks, I changed to O.

              – Ulrike Fischer
              Jan 4 at 17:05











            • I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

              – BJPrim
              Jan 4 at 17:08











            • That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

              – egreg
              Jan 4 at 17:08






            • 1





              You can remove xfp and replace fpeval by fp_eval:n.

              – Ulrike Fischer
              Jan 4 at 17:23










            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468597%2fconvert-decimal-to-percentage-value%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            You can use the siunitx package:



            documentclassarticle

            usepackagesiunitx

            newcommandpercentage[2][round-precision = 2]% default precision: 2
            SI[round-mode = places,
            scientific-notation = fixed, fixed-exponent = 0,
            output-decimal-marker=., #1]#2e2percent%


            begindocument

            percentage0.123456 % -> 12.35 %
            percentage[round-precision = 3]0.123456 % -> 12.345 %

            enddocument





            share|improve this answer





























              5














              You can use the siunitx package:



              documentclassarticle

              usepackagesiunitx

              newcommandpercentage[2][round-precision = 2]% default precision: 2
              SI[round-mode = places,
              scientific-notation = fixed, fixed-exponent = 0,
              output-decimal-marker=., #1]#2e2percent%


              begindocument

              percentage0.123456 % -> 12.35 %
              percentage[round-precision = 3]0.123456 % -> 12.345 %

              enddocument





              share|improve this answer



























                5












                5








                5







                You can use the siunitx package:



                documentclassarticle

                usepackagesiunitx

                newcommandpercentage[2][round-precision = 2]% default precision: 2
                SI[round-mode = places,
                scientific-notation = fixed, fixed-exponent = 0,
                output-decimal-marker=., #1]#2e2percent%


                begindocument

                percentage0.123456 % -> 12.35 %
                percentage[round-precision = 3]0.123456 % -> 12.345 %

                enddocument





                share|improve this answer















                You can use the siunitx package:



                documentclassarticle

                usepackagesiunitx

                newcommandpercentage[2][round-precision = 2]% default precision: 2
                SI[round-mode = places,
                scientific-notation = fixed, fixed-exponent = 0,
                output-decimal-marker=., #1]#2e2percent%


                begindocument

                percentage0.123456 % -> 12.35 %
                percentage[round-precision = 3]0.123456 % -> 12.345 %

                enddocument






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 4 at 17:22

























                answered Jan 4 at 16:48









                zetaeffezetaeffe

                3165




                3165





















                    4














                    Your values looks wrong. But beside this:



                    documentclassarticle
                    usepackagexfp,xparse
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    fpevalround(#2*100,l_bjprim_round_int)%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    If you really want to fill up with zeros you could round with siunitx:



                    documentclassarticle
                    usepackagexfp,xparse,siunitx
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    num[round-mode = places,round-precision=l_bjprim_round_int]fpeval#2*100%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    enter image description here






                    share|improve this answer

























                    • This way the optional argument is actually mandatory.

                      – egreg
                      Jan 4 at 16:59











                    • @egreg thanks, I changed to O.

                      – Ulrike Fischer
                      Jan 4 at 17:05











                    • I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                      – BJPrim
                      Jan 4 at 17:08











                    • That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                      – egreg
                      Jan 4 at 17:08






                    • 1





                      You can remove xfp and replace fpeval by fp_eval:n.

                      – Ulrike Fischer
                      Jan 4 at 17:23















                    4














                    Your values looks wrong. But beside this:



                    documentclassarticle
                    usepackagexfp,xparse
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    fpevalround(#2*100,l_bjprim_round_int)%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    If you really want to fill up with zeros you could round with siunitx:



                    documentclassarticle
                    usepackagexfp,xparse,siunitx
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    num[round-mode = places,round-precision=l_bjprim_round_int]fpeval#2*100%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    enter image description here






                    share|improve this answer

























                    • This way the optional argument is actually mandatory.

                      – egreg
                      Jan 4 at 16:59











                    • @egreg thanks, I changed to O.

                      – Ulrike Fischer
                      Jan 4 at 17:05











                    • I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                      – BJPrim
                      Jan 4 at 17:08











                    • That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                      – egreg
                      Jan 4 at 17:08






                    • 1





                      You can remove xfp and replace fpeval by fp_eval:n.

                      – Ulrike Fischer
                      Jan 4 at 17:23













                    4












                    4








                    4







                    Your values looks wrong. But beside this:



                    documentclassarticle
                    usepackagexfp,xparse
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    fpevalround(#2*100,l_bjprim_round_int)%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    If you really want to fill up with zeros you could round with siunitx:



                    documentclassarticle
                    usepackagexfp,xparse,siunitx
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    num[round-mode = places,round-precision=l_bjprim_round_int]fpeval#2*100%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    enter image description here






                    share|improve this answer















                    Your values looks wrong. But beside this:



                    documentclassarticle
                    usepackagexfp,xparse
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    fpevalround(#2*100,l_bjprim_round_int)%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    If you really want to fill up with zeros you could round with siunitx:



                    documentclassarticle
                    usepackagexfp,xparse,siunitx
                    ExplSyntaxOn
                    int_new:Nl_bjprim_round_int
                    keys_define:nn bjprim

                    positions-after-comma .int_set:N = l_bjprim_round_int


                    NewDocumentCommandpercentage O m

                    keys_set:nn bjprimpositions-after-comma=2,#1
                    num[round-mode = places,round-precision=l_bjprim_round_int]fpeval#2*100%

                    ExplSyntaxOff
                    begindocument


                    percentage[positions-after-comma = 2]0.123456: 12.12%

                    percentage[positions-after-comma = 4]0.123456: 12.1235%

                    percentage[positions-after-comma = 4]2.123456: 212.1235%

                    percentage[positions-after-comma = 1]0.6789: 67.9%

                    percentage[positions-after-comma = 5]0.6789: 67.89000%

                    enddocument


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jan 4 at 17:05

























                    answered Jan 4 at 16:45









                    Ulrike FischerUlrike Fischer

                    188k7294673




                    188k7294673












                    • This way the optional argument is actually mandatory.

                      – egreg
                      Jan 4 at 16:59











                    • @egreg thanks, I changed to O.

                      – Ulrike Fischer
                      Jan 4 at 17:05











                    • I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                      – BJPrim
                      Jan 4 at 17:08











                    • That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                      – egreg
                      Jan 4 at 17:08






                    • 1





                      You can remove xfp and replace fpeval by fp_eval:n.

                      – Ulrike Fischer
                      Jan 4 at 17:23

















                    • This way the optional argument is actually mandatory.

                      – egreg
                      Jan 4 at 16:59











                    • @egreg thanks, I changed to O.

                      – Ulrike Fischer
                      Jan 4 at 17:05











                    • I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                      – BJPrim
                      Jan 4 at 17:08











                    • That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                      – egreg
                      Jan 4 at 17:08






                    • 1





                      You can remove xfp and replace fpeval by fp_eval:n.

                      – Ulrike Fischer
                      Jan 4 at 17:23
















                    This way the optional argument is actually mandatory.

                    – egreg
                    Jan 4 at 16:59





                    This way the optional argument is actually mandatory.

                    – egreg
                    Jan 4 at 16:59













                    @egreg thanks, I changed to O.

                    – Ulrike Fischer
                    Jan 4 at 17:05





                    @egreg thanks, I changed to O.

                    – Ulrike Fischer
                    Jan 4 at 17:05













                    I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                    – BJPrim
                    Jan 4 at 17:08





                    I am struggling to get your code running. It says: "File `xfp.sty' not found." I am working with Overleaf, can it be that this package is not supported?

                    – BJPrim
                    Jan 4 at 17:08













                    That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                    – egreg
                    Jan 4 at 17:08





                    That's not what I meant; if you use percentage<number>, the previous value is used, which may or may not be desired.

                    – egreg
                    Jan 4 at 17:08




                    1




                    1





                    You can remove xfp and replace fpeval by fp_eval:n.

                    – Ulrike Fischer
                    Jan 4 at 17:23





                    You can remove xfp and replace fpeval by fp_eval:n.

                    – Ulrike Fischer
                    Jan 4 at 17:23

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468597%2fconvert-decimal-to-percentage-value%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?