❔ Why is my decimal rounding?
I have to be missing something obvious but I would appreciate some help >.>
with merchant.markup = 20, the decimal markup should be 1.2 but it's 1
'
11 Replies
what type is
CurrentMerchant.Markup
?int
yeah, int / int gives you an int
you need to cast either the left or right side to a floating point type
hmm okay i'll see what that is
simplest way is changing
100
to 100.0
which makes it a double instead of an int
there are also suffixes you can add to number literals to make them a specific type, like:
ahhhhh okay i remember this a little XD thank you so much
there are a lot of cats here
you say that like it's a problem
/mom-come-pick-me-up-there-are-cats-here
For bare values it's best to supply the type by suffix, subtle bugs otherwise
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.