//Title: Currency Output
//Credit to: Jtgibson
//Contributed by: Jtgibson
//Run a number through the dollar proc to spit
// out a proper dollar figure.
//Originally designed this proc for my stillborn entry for the
// BYONDscape 4K Challenge 2002.
proc/dollar(n)
n=round(n,0.01)
var/d=round(n)
var/c=round((n-round(n))*100,1)
if(c<10) c = "0[num2text(c,20)]"
else c = num2text(c,20)
return("$[num2text(d,20)].[c]")
///*
//Testing code/sample implementation
mob/verb/test_dollar()
usr << "dollar(1.25) = [dollar(1.25)]"
usr << "dollar(1.125) = [dollar(1.125)]"
usr << "dollar(1.066) = [dollar(1.066)]"
usr << "dollar(1) = [dollar(1)]"
//*/
ID:195116
Nov 21 2006, 8:02 am
|
|