Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
They're used case by case, for percision usually. // returns int and / returns float. Examples: if i have a program that uses threads, but the amount of values per thread depends on the amount of values given - take the total number of values and hard divide // it by the number of threads! if i have a class that prints out the percentage values of a job getting done. Sometimes the percentages can have very small increments depending on the amount of work. Because of these smaller increments, i'd like more percision so i use regular division to get a float value for the percentage.
22nd May 2021, 2:07 PM
Slick
Slick - avatar