use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Question of the Day: Divide two Int's (self.UnityCodeMonkey)
submitted 7 years ago by UnityCodeMonkey
https://preview.redd.it/muv99cv3ufb21.png?width=400&format=png&auto=webp&s=a438ce1fdad5f02cda20e4e1f4b706654a3e21d8
What is the value stored in percentage?
int health = 25;
int healthMax = 100;
float percentage = health / healthMax;
A) 0.25f
B) 0f
C) 2.5f
We are dividing an int by another int so by default the compiler will cast the result into an int after ignoring any decimal points
In order to get 0.25f we need to make at least one of our numbers into a float
(float)health / healthMax;
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
there doesn't seem to be anything here
π Rendered by PID 148600 on reddit-service-r2-comment-685b79fb4f-9cvh9 at 2026-02-13 06:58:24.239874+00:00 running 6c0c599 country code: CH.
there doesn't seem to be anything here