Answers for "float decimal places"

4

show 2 decimals of float

// You can use .ToString("f2") to show 2 decimals of "f3" to show 3, etc.
float num = 123.24523;

Debug.Log(num.ToString("f2")); // Output: 123.24
Posted by: Guest on October-29-2021
0

float format decimal places

num = 1.234
print("{:.2f}".format(num))
>> 1.23

print(f"{num:.2f}")
>> 1.23
Posted by: Guest on November-04-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language