Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

1 total

Round.. when there is no round

I needed a math.round in Javascript, there was none available in my environment... a new japanese phone
function Round(number){
	newnumber=number*10;
	remainder=newnumber%10;
	newnumber-=remainder;
	if(remainder>5){
		newnumber+=10;
	}
	newnumber=newnumber/10;
	if(newnumber%1!=0){
		newnumber=Round(newnumber*10)/10
	}
	return newnumber;
}

ie. alert (Round(66.3523)) should give 66
1 total