Finding Decimal Places

Discussion in 'ASP General' started by Brent Bortnick, Jul 2, 2003.

  1. 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
    Brent Bortnick, Jul 2, 2003
    #1
    1. Advertising

  2. Brent Bortnick

    Evertjan. Guest

    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)
    Evertjan., Jul 2, 2003
    #2
    1. Advertising

  3. Brent Bortnick

    Evertjan. Guest

    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)
    Evertjan., Jul 2, 2003
    #3
  4. 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

    >
    >
    >.
    >
    Brent Bortnick, Jul 2, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eoin Mcloughlin

    Decimal places and huge fractions.

    Eoin Mcloughlin, Feb 11, 2004, in forum: Perl
    Replies:
    5
    Views:
    1,598
    Eoin Mcloughlin
    Feb 13, 2004
  2. Curt_C [MVP]

    Re: beginner: prob with decimal places

    Curt_C [MVP], May 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    329
    Curt_C [MVP]
    May 18, 2004
  3. Curt_C [MVP]

    Re: beginner: prob with decimal places

    Curt_C [MVP], May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    537
    Curt_C [MVP]
    May 18, 2004
  4. Harry

    Remove Decimal Places

    Harry, Jun 3, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    8,924
    VB Programmer
    Jun 3, 2004
  5. Bharat Bhushan

    Decimal Places

    Bharat Bhushan, Aug 8, 2003, in forum: Java
    Replies:
    2
    Views:
    481
    Lee Weiner
    Aug 8, 2003
Loading...

Share This Page