Using Integer in a Double after the Comma
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
add a comment |
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
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
add a comment |
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
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
c# int double
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Nov 19 '18 at 20:01
user3617117user3617117
111
111
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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