pacai.util.math
1import math 2 3def display_number(value: float, places: int = 2) -> str: 4 """ 5 Format a number as a string for display purposes. 6 If the value is an integer, don't use any decimal places. 7 Otherwise, use the given number of places. 8 """ 9 10 if (math.isclose(value, int(value))): 11 return str(int(value)) 12 13 return f"%.{places}f" % (value)
def
display_number(value: float, places: int = 2) -> str:
4def display_number(value: float, places: int = 2) -> str: 5 """ 6 Format a number as a string for display purposes. 7 If the value is an integer, don't use any decimal places. 8 Otherwise, use the given number of places. 9 """ 10 11 if (math.isclose(value, int(value))): 12 return str(int(value)) 13 14 return f"%.{places}f" % (value)
Format a number as a string for display purposes. If the value is an integer, don't use any decimal places. Otherwise, use the given number of places.