Is there a code that changes decimal places? Example if you have 333.333333..... can you make it say just 333

Thanks

Recommended Answers

All 2 Replies

This can make it 333

Test this code in your addresbar:

javascript: alert(333.33333.toFixed())

implement it if you like it.

You can also do things like:
3215.3248566432.toFixed() //gives you [3215]
3215.3248566432.toFixed(1) //gives you [3215.3]
3215.3248566432.toFixed(3) //gives you [3215.325]
3215.3248566432.toFixed(4) //gives you [3215.3249]

etc

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.