Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Finding Decimal Places

Reply
Thread Tools

Finding Decimal Places

 
 
Brent Bortnick
Guest
Posts: n/a
 
      07-02-2003
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
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      07-02-2003
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)
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      07-02-2003
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)
 
Reply With Quote
 
Brent Bortnick
Guest
Posts: n/a
 
      07-02-2003
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 many
>decimal places there are in the variable "decimal"
>
>
>
>"Brent Bortnick" <> wrote in message
>news:42e501c340ce$a6001610$...
>> 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

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove Decimal Places Harry ASP .Net 3 06-03-2004 07:19 PM
Re: beginner: prob with decimal places Curt_C [MVP] ASP .Net 2 05-18-2004 08:38 PM
Re: beginner: prob with decimal places Curt_C [MVP] ASP .Net 1 05-18-2004 07:27 PM
Decimal places and huge fractions. Eoin Mcloughlin Perl 5 02-13-2004 08:33 PM
Decimal Places Bharat Bhushan Java 2 08-08-2003 05:28 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57