C
C#3y ago
matuda.

❔ Percentage

How do I calculate percentage in C#?
10 Replies
TheBoxyBear
TheBoxyBear3y ago
Like with basic math If you have a decimal number 0-1, just multiply by 100
matuda.
matuda.OP3y ago
so if i have 15% i made 15*100 ?
matuda.
matuda.OP3y ago
matuda.
matuda.OP3y ago
I've got this problem and i tried different things like Total*10/15 . Was work it until it didn't make it when i whrite 4,3,1,2. It answered 8 but i need 7 i just need to know how to write the formula and that's all
canton7
canton73y ago
15/100 is 0, because that's doing integer division. If you're working with decimal, you probabli want 15m/100m, which does decimal division between two decimal numbers
MODiX
MODiX3y ago
Toshiya Joshima#3472
REPL Result: Success
15/100
15/100
Result: int
0
0
Compile: 331.142ms | Execution: 65.189ms | React with ❌ to remove this embed.
MODiX
MODiX3y ago
Toshiya Joshima#3472
REPL Result: Success
15m/100m
15m/100m
Result: decimal
0.15
0.15
Compile: 375.399ms | Execution: 17.944ms | React with ❌ to remove this embed.
matuda.
matuda.OP3y ago
thanks
MODiX
MODiX3y ago
Jester#8471
REPL Result: Success
$"{0.69:P}"
$"{0.69:P}"
Result: string
69.00 %
69.00 %
Compile: 518.768ms | Execution: 33.778ms | React with ❌ to remove this embed.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server