By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Finding Decimal Places

P: n/a
Does anyone know how to find out the number of decimal
places a number has. I need this info so that i can round
to 3 decimal places if the number has 3 decimal places or
to 2 decimal places if the number has 2 decimal places.

Any help would be great.

Regards,

Brent
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Brent Bortnick wrote on 02 jul 2003 in
microsoft.public.inetserver.asp.general:
Does anyone know how to find out the number of decimal
places a number has. I need this info so that i can round
to 3 decimal places if the number has 3 decimal places or
to 2 decimal places if the number has 2 decimal places.


If this is so there is no need to round,

or I do not understand what "having decimal places" means for a number.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

P: n/a
Andrew Paton wrote on 02 jul 2003 in
microsoft.public.inetserver.asp.general:
Try something like

<%
decimal = 0.001

pointposition = instr(decimal,".")
noplaces = len(decimal) - pointposition
%>

This should return (well it does i tested it) a value of 3. Or however
many decimal places there are in the variable "decimal"


This is where vbs InStrRev() is for

<%
decimal = 0.001
noplaces = len(decimal) - InStrRev(decimal,".")
%>

Beware, localized versions sometimes need InStrRev(decimal,",")

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3

P: n/a
Thanks That worked.
-----Original Message-----
Try something like

<%
decimal = 0.001

pointposition = instr(decimal,".")
noplaces = len(decimal) - pointposition
%>

This should return (well it does i tested it) a value of 3. Or however manydecimal places there are in the variable "decimal"

"Brent Bortnick" <br***@hitechseals.com> wrote in message
news:42****************************@phx.gbl...
Does anyone know how to find out the number of decimal
places a number has. I need this info so that i can round to 3 decimal places if the number has 3 decimal places or to 2 decimal places if the number has 2 decimal places.

Any help would be great.

Regards,

Brent

.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.