posted 14 years ago
Mmm, NumberFormat won't really do it for you, as it uses proper rounding, not truncation. Unless of course you wish to abandon truncation for something that, well, makes much more sense?
That is to say: in the real world, 8.5679 should really be rounded to 8.57 rather than 8.56, as the former is a much closer approximation. Do you really need to represent this as 8.56?
If, for some reason, you really do need this, I suggest looking at Math.floor(). Of course, this only rounds down to the nearest lower integer value. But, hey - that's what basic math operations like multiplication and division are for. (Well, one reason for their existence, anyway.) Consider: what happens if you multiply a value by 100? And what happens if you divide by 100? With a few simple mathematical operations, you can achieve the result you desire - if indeed you still do desire it.