how would i go about rounding and displaying numbers, such as:
1,239,120
to 1.239 Million

Thanks 😃

  • xyz replied to this.
  • this works ...

    func make_pretty_numbers( num:float, precission:int=2  ) -> String:
    	var unit:String
    	if num > 1000000000:
    		num /= 1000000000
    		unit = "giga"
    	elif num > 1000000:
    		num /= 1000000
    		unit = "mega"
    	elif num > 1000:
    		num /= 1000
    		unit = "kilo"
    	else:
    		unit = "base"
    	
    	return str("%."+str(precission)+"f "+unit) % [num]

    this works ...

    func make_pretty_numbers( num:float, precission:int=2  ) -> String:
    	var unit:String
    	if num > 1000000000:
    		num /= 1000000000
    		unit = "giga"
    	elif num > 1000000:
    		num /= 1000000
    		unit = "mega"
    	elif num > 1000:
    		num /= 1000
    		unit = "kilo"
    	else:
    		unit = "base"
    	
    	return str("%."+str(precission)+"f "+unit) % [num]