how to force decimals to display in exponential notation

Discussion in 'ASP General' started by revansx, Oct 15, 2006.

  1. revansx

    revansx Guest

    Hi folks,

    I am programming a page that displays scientific data retrieved from a
    data source to an asp-web page and i would like to force all number to
    be formatted/displayed in scientific notation no matter what the value
    is. (i.e. x = 123 would be displayed as x = 1.23e+02). The standard
    function "formatnumeric(x[,n])" does not seem to be able to do this for
    me or at least I don't know how to use it that way.

    Can anyone show mw a way?

    -rich evans
    revansx, Oct 15, 2006
    1. Advertisements

  2. revansx

    revansx Guest

    Hi Dave,

    Thanks for the quick reply.

    Isn't JScript a client-side scripting language?
    I really need to be able to do this on the server-side.
    ....or did I misunderstand your solution?

    - rich
    revansx, Oct 16, 2006
    1. Advertisements

  3. No. JScript is a scripting language.
    ASP support several scripting languages, including vbscript and jscript,
    as well as others. See this for tips:

    It is really incorrect to use "javascript" interchangeably with
    "client-side script". IE supports the use of both vbscript and jscript
    in client-side script. Other browsers only support javascript ... hence
    the propensity for using the terms interchangeable.
    Yes. He intended you to implement it in a server-side script block.
    Bob Barrows [MVP], Oct 16, 2006
  4. JScript is availabel as a scripting language in ASP. I use it exclusively.

    Now, I am not saying you need to change languages (though I think the
    benefits of using JScript for ASP are many). ASP actually allows you to use
    both languages in the same script. There are some rules to keep in mind,

    To begin with, understand that there are three distinctly different types of
    scripting blocks:

    1. <script runat="server" language="jscript"> ... </script>
    2. <script runat="server" language="vbscript"> ... </script>
    3. <% ... %>

    I will refer to #3 as "inline" from here on.

    When the script is parsed, the parser determines the language for inline
    scripting, then executes the blocks in the following order: 1-3-2 (if inline
    language is VBScript), or 2-3-1 (if JScript). HOWEVER, any block can call a
    function from any other block. It does not matter what order the blocks
    appear within the script.

    If you want to mix-and-match languages, then, it is a good practice to
    encapsulate the cross-language bits in functions:


    Dim N : N = 100 * Rnd()

    <script runat="server" language="jscript">
    function FormatEXP(n,d) {
    return n.toExponential(d)
    Dave Anderson, Oct 16, 2006
  5. revansx

    revansx Guest

    many thanks,

    - rich
    revansx, Oct 16, 2006
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.