Does GDScript have currency formatting?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By OrdinaryMan

For example: display 10000 as 10,000 etc

I couldn’t find the answer in the docs or in this forum

:bust_in_silhouette: Reply From: cgeadas

I don’t think it has.

But it can easily be solved with something simple like this, but better programmed.

func _ready():

	print(get_currency(50000))
	

static func get_currency(number):
	
	# Place the decimal separator
	var txt_numb = "%.2f" % number
	
	# Place the thousands separator
	for idx in range(txt_numb.find(".") - 3, 0, -3):
		txt_numb = txt_numb.insert(idx, ",")
	return(txt_numb)

It will print 50,000.00