❔ 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
CLOAKERWAVEOP3y 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
phaseshift3y ago
What is the type of Discount?
CLOAKERWAVE
CLOAKERWAVEOP3y ago
Int Should the variable be set to double?
CLOAKERWAVE
CLOAKERWAVEOP3y ago
phaseshift
phaseshift3y ago
Well, an int can't describe numbers like 0.5.
CLOAKERWAVE
CLOAKERWAVEOP3y ago
Ah What should I set it to, if anything?
phaseshift
phaseshift3y ago
If you don't care about a bit of rounding error, float. Otherwise decimal
CLOAKERWAVE
CLOAKERWAVEOP3y ago
Thanks man, I really appreciate it I'm new to coding in general lol, thanks again
$U₹¥Δ
$U₹¥Δ3y ago
try using casting to decimal Ex: decimal number = (decimal)integer * 0.8m;
Accord
Accord3y 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.

Did you find this page helpful?