Xiija Posted June 19, 2023 Share Posted June 19, 2023 (edited) nvm Edited June 19, 2023 by Xiija Link to comment Share on other sites More sharing options...
Frionil Fang Posted June 19, 2023 Share Posted June 19, 2023 You're dividing 2 integers, which means the result will be an integer. (4388 / 65536)*100 = 0*100 = 0. If you changed the order of operations to 100*4388/65536, the answer would be 6 (integer division rounds towards 0). To use float division, you must cast to float (float percent = ((float)used/65536)*100), or, in this case since you're hardcoding the values and I won't question that, you can use a float literal (float percent = (4388.0/65536)*100). 1 Link to comment Share on other sites More sharing options...
elleevelyn Posted June 20, 2023 Share Posted June 20, 2023 adding on. A fyi using the first example: 100*4388/65536 when we code the constant integer 100 as a float then is an implicit cast float percent = 100.0 * used / limit; // where used and limit are integer type // percent = 6.695557 Link to comment Share on other sites More sharing options...
Xiija Posted June 20, 2023 Author Share Posted June 20, 2023 ty all 1 Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted June 20, 2023 Share Posted June 20, 2023 2 2 1 Link to comment Share on other sites More sharing options...
PheebyKatz Posted June 30, 2023 Share Posted June 30, 2023 And another one receives shared knowledge and removes the possibility of sharing that knowledge with others. How selfish can people be with the generosity they receive? This is like a hungry person asking for food and when you share with them they take a dump in the pot so nobody else can eat any. 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted June 30, 2023 Share Posted June 30, 2023 1 hour ago, PheebyKatz said: This is like a hungry person asking for food and when you share with them they take a dump in the pot so nobody else can eat any. Eewww!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now