C
C#2y ago
Bujju

✅ Incorrect math

(3 / 4) * 100 returns 0, when it should return 75. Why is this?
4 Replies
Jimmacle
Jimmacle2y ago
you're using integers, they can only represent whole numbers 3/4 is 0 you need to make at least one number a floating point number to coerce the rest into being floating point like (3 / 4f) * 100
Auger
Auger2y ago
Or for additional precision, cast one of the numbers into a double.
Bujju
Bujju2y ago
Thanks
Accord
Accord2y ago
Closed!
Want results from more Discord servers?
Add your server
More Posts
❔ Antiforgery token validation in API'sAntiforgery tokens are for preventing cross-site request forgery. Does that mean all sensitive API's✅ Naming functions using stringsIn Kotlin, it is possible to name function as strings surrounded by ` `. Thus we can have white spac❔ How should i asociate button click as enterI want to make like if i press enter my app will give u the number but i dont know how to use input ✅ Check a box on a websiteHow can I check a box on a local website using c#? Havent found anything on googleIs it possible to create a program that just goes on a specific url,logs in and then activates smth?I wanted to create smth quick to enable/disable the routers 5ghz option.. it runs on a local/private✅ How should I structure 'exit points' in my program?Hey guys. I'm working solo on a project that involves opening an Excel file, sorting through and tr❔ Does this method cause boxing of value types?I was looking through the list<T> class and noticed that the Contains<T>(T item) method attemps to c❔ Help with realization Division by zero in wpf projectI want to throw out the error when dividing by zero. Since "Compute" gives infinity when divided by Get data from a model and display it as dropdown on client side in RazorHi, how do I retrieve data in a database from a model and show it in as my dropdown values in my raz❔ Help with DI, i have different connection strings but same behavior for query DBHi, i want to instance the same query service but with different configuration and i have no idea ho