# Limit length of number irrespect of decimal places

• Nov 18, 2009, 11:36
skyline
Limit length of number irrespect of decimal places
I need to return a max of 8 digits to any number (not inc decimal point if necessary), but also want a max of 4 decimal places if the calculation provides a results with more than 4 dec places. This is because i have a max space of 8 characters + dec place.

eg

10.0908 (fewer than 8 digits so full 4 decimal places)
1908978.5 (max digits so could only return 1 dec place)
222.0192 (fewer than 8 digits so full 4 dec places shown)
1.19 (this is full answer so no changes required as !=> 8 digits & dec places<4 any way)

Hope this makes sense!!
• Nov 18, 2009, 11:48
crmalibu
What is the result?

123456.7555
• Nov 18, 2009, 12:00
Zarin Denatrose
For that matter, what would the result of 1234567890 be? Do non-fractional numbers keep their whole value?
• Nov 18, 2009, 12:16
skyline
Actually seems ok to squeeze any 9 characters in, so partly solved by this:

\$charLimit = 9;