Using Integer in a Double after the Comma












-2














What i Exactly mean is that i want to Do it like 0,integer but i have no idea How to do it, Is there any way that I could do that? I really Need It to get Working, Have been Searching for the Past 30 Minutes with no Luck or anything similliar to what Im seeking.



double a = done / 10.ToString().Length;
zeros = Math.Floor(Math.Log10(a) + 1) - 6 ;
double prepared;

double toAdd = done / 10;
if(zeros == 0)
{
prepared = 0,zeroes;
}









share|improve this question




















  • 2




    You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
    – maccettura
    Nov 19 '18 at 19:54










  • edited, i hope its more understandable
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:55






  • 1




    Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
    – maccettura
    Nov 19 '18 at 19:57










  • I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:58








  • 1




    @ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
    – Christopher
    Nov 19 '18 at 20:05
















-2














What i Exactly mean is that i want to Do it like 0,integer but i have no idea How to do it, Is there any way that I could do that? I really Need It to get Working, Have been Searching for the Past 30 Minutes with no Luck or anything similliar to what Im seeking.



double a = done / 10.ToString().Length;
zeros = Math.Floor(Math.Log10(a) + 1) - 6 ;
double prepared;

double toAdd = done / 10;
if(zeros == 0)
{
prepared = 0,zeroes;
}









share|improve this question




















  • 2




    You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
    – maccettura
    Nov 19 '18 at 19:54










  • edited, i hope its more understandable
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:55






  • 1




    Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
    – maccettura
    Nov 19 '18 at 19:57










  • I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:58








  • 1




    @ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
    – Christopher
    Nov 19 '18 at 20:05














-2












-2








-2







What i Exactly mean is that i want to Do it like 0,integer but i have no idea How to do it, Is there any way that I could do that? I really Need It to get Working, Have been Searching for the Past 30 Minutes with no Luck or anything similliar to what Im seeking.



double a = done / 10.ToString().Length;
zeros = Math.Floor(Math.Log10(a) + 1) - 6 ;
double prepared;

double toAdd = done / 10;
if(zeros == 0)
{
prepared = 0,zeroes;
}









share|improve this question















What i Exactly mean is that i want to Do it like 0,integer but i have no idea How to do it, Is there any way that I could do that? I really Need It to get Working, Have been Searching for the Past 30 Minutes with no Luck or anything similliar to what Im seeking.



double a = done / 10.ToString().Length;
zeros = Math.Floor(Math.Log10(a) + 1) - 6 ;
double prepared;

double toAdd = done / 10;
if(zeros == 0)
{
prepared = 0,zeroes;
}






c# int double






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 19:56









maccettura

8,27931426




8,27931426










asked Nov 19 '18 at 19:52









Arkadiusz BrzozaArkadiusz Brzoza

65




65








  • 2




    You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
    – maccettura
    Nov 19 '18 at 19:54










  • edited, i hope its more understandable
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:55






  • 1




    Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
    – maccettura
    Nov 19 '18 at 19:57










  • I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:58








  • 1




    @ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
    – Christopher
    Nov 19 '18 at 20:05














  • 2




    You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
    – maccettura
    Nov 19 '18 at 19:54










  • edited, i hope its more understandable
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:55






  • 1




    Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
    – maccettura
    Nov 19 '18 at 19:57










  • I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
    – Arkadiusz Brzoza
    Nov 19 '18 at 19:58








  • 1




    @ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
    – Christopher
    Nov 19 '18 at 20:05








2




2




You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
– maccettura
Nov 19 '18 at 19:54




You need to give us examples of what you want -- "Do it like 0,integer" means absolutely nothing to me
– maccettura
Nov 19 '18 at 19:54












edited, i hope its more understandable
– Arkadiusz Brzoza
Nov 19 '18 at 19:55




edited, i hope its more understandable
– Arkadiusz Brzoza
Nov 19 '18 at 19:55




1




1




Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
– maccettura
Nov 19 '18 at 19:57




Its not that much more understandable honestly. Speak in plain terms what you want the functionality to be. Do you want to control the number of zeroes when displaying a double?
– maccettura
Nov 19 '18 at 19:57












I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
– Arkadiusz Brzoza
Nov 19 '18 at 19:58






I have a Integer, which Determines how many Zeroes after the Comma should go, and Now i need to Figure out how to make this work so i can use the Integer after the Comma. so for Example zeroes = 3 so prepared = 0,zeroes which should output 0,000
– Arkadiusz Brzoza
Nov 19 '18 at 19:58






1




1




@ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
– Christopher
Nov 19 '18 at 20:05




@ArkadiuszBrzoza: That is either padding (up to a multiple of 3) or a format string that forces that. Neither idea is ideal and will propably break the moment you try to change the culture this is executed in. Would it not be easier to just have the last digit of the integer be at the last decimal place to begin with?
– Christopher
Nov 19 '18 at 20:05












1 Answer
1






active

oldest

votes


















0














so you want to divide by 10 and round to 1 or more decimals?



  using System;

public class Sample {
static void Main() {
Console.WriteLine(Math.Round(3.44m, 1));
Console.WriteLine(Math.Round(3.45m, 1));
Console.WriteLine(Math.Round(3.46m, 1));
Console.WriteLine();

Console.WriteLine(Math.Round(4.34m, 1));
Console.WriteLine(Math.Round(4.35m, 1));
Console.WriteLine(Math.Round(4.36m, 1));
}
}
// The example displays the following output:
// 3.4
// 3.4
// 3.5
//
// 4.3
// 4.4
// 4.4


retrieve from: https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#Round3_Example






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2fstackoverflow.com%2fquestions%2f53381706%2fusing-integer-in-a-double-after-the-comma%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    so you want to divide by 10 and round to 1 or more decimals?



      using System;

    public class Sample {
    static void Main() {
    Console.WriteLine(Math.Round(3.44m, 1));
    Console.WriteLine(Math.Round(3.45m, 1));
    Console.WriteLine(Math.Round(3.46m, 1));
    Console.WriteLine();

    Console.WriteLine(Math.Round(4.34m, 1));
    Console.WriteLine(Math.Round(4.35m, 1));
    Console.WriteLine(Math.Round(4.36m, 1));
    }
    }
    // The example displays the following output:
    // 3.4
    // 3.4
    // 3.5
    //
    // 4.3
    // 4.4
    // 4.4


    retrieve from: https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#Round3_Example






    share|improve this answer


























      0














      so you want to divide by 10 and round to 1 or more decimals?



        using System;

      public class Sample {
      static void Main() {
      Console.WriteLine(Math.Round(3.44m, 1));
      Console.WriteLine(Math.Round(3.45m, 1));
      Console.WriteLine(Math.Round(3.46m, 1));
      Console.WriteLine();

      Console.WriteLine(Math.Round(4.34m, 1));
      Console.WriteLine(Math.Round(4.35m, 1));
      Console.WriteLine(Math.Round(4.36m, 1));
      }
      }
      // The example displays the following output:
      // 3.4
      // 3.4
      // 3.5
      //
      // 4.3
      // 4.4
      // 4.4


      retrieve from: https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#Round3_Example






      share|improve this answer
























        0












        0








        0






        so you want to divide by 10 and round to 1 or more decimals?



          using System;

        public class Sample {
        static void Main() {
        Console.WriteLine(Math.Round(3.44m, 1));
        Console.WriteLine(Math.Round(3.45m, 1));
        Console.WriteLine(Math.Round(3.46m, 1));
        Console.WriteLine();

        Console.WriteLine(Math.Round(4.34m, 1));
        Console.WriteLine(Math.Round(4.35m, 1));
        Console.WriteLine(Math.Round(4.36m, 1));
        }
        }
        // The example displays the following output:
        // 3.4
        // 3.4
        // 3.5
        //
        // 4.3
        // 4.4
        // 4.4


        retrieve from: https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#Round3_Example






        share|improve this answer












        so you want to divide by 10 and round to 1 or more decimals?



          using System;

        public class Sample {
        static void Main() {
        Console.WriteLine(Math.Round(3.44m, 1));
        Console.WriteLine(Math.Round(3.45m, 1));
        Console.WriteLine(Math.Round(3.46m, 1));
        Console.WriteLine();

        Console.WriteLine(Math.Round(4.34m, 1));
        Console.WriteLine(Math.Round(4.35m, 1));
        Console.WriteLine(Math.Round(4.36m, 1));
        }
        }
        // The example displays the following output:
        // 3.4
        // 3.4
        // 3.5
        //
        // 4.3
        // 4.4
        // 4.4


        retrieve from: https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#Round3_Example







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 20:01









        user3617117user3617117

        111




        111






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fstackoverflow.com%2fquestions%2f53381706%2fusing-integer-in-a-double-after-the-comma%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

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith