http://qs1969.pair.com?node_id=87691


in reply to (Golf) Giving Change

Assuming that your lowest denomination >= 0.000001, you can get around the scaling in your code using sprintf (94 chars here):
sub c{($t,$p,@r)=@_;while($v=pop@$p and$t>0) {while($t>=$v){push@r,$v;$t=sprintf"%f",$t-$v}}@r}

update: added reinit of @r, comment about limits on smallest denomination (change %f to "%9f" for 1e-9 limit), change %g to %f
Works for larger numbers:
print join(',',c(22500020,[.01,.05,.1,1,2,5,10,20,50,100,1e3,1e4,1e5,1e6])); 1000000,1000000,1000000,1000000,1000000,1000000,1000000, 1000000,1000000,1000000,1000000,1000000,1000000,1000000, 1000000,1000000,1000000,1000000,1000000,1000000,1000000, 1000000,100000,100000,100000,100000,100000,20