❔ Attempting to multiply a number by a decimal, keeps getting 0

Hello, I am attempting to multiply a number by .5, and whenever I do the end result is 0.
10 Replies
CLOAKERWAVE
CLOAKERWAVEOP2y ago
There's nothing wrong with it when it is a single digit number, but whenever I change Discount to any type of decimal it just goes to 0
phaseshift
phaseshift2y ago
What is the type of Discount?
CLOAKERWAVE
CLOAKERWAVEOP2y ago
Int Should the variable be set to double?
CLOAKERWAVE
CLOAKERWAVEOP2y ago
phaseshift
phaseshift2y ago
Well, an int can't describe numbers like 0.5.
CLOAKERWAVE
CLOAKERWAVEOP2y ago
Ah What should I set it to, if anything?
phaseshift
phaseshift2y ago
If you don't care about a bit of rounding error, float. Otherwise decimal
CLOAKERWAVE
CLOAKERWAVEOP2y ago
Thanks man, I really appreciate it I'm new to coding in general lol, thanks again
$U₹¥Δ
$U₹¥Δ2y ago
try using casting to decimal Ex: decimal number = (decimal)integer * 0.8m;
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