469,568 Members | 1,439 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,568 developers. It's quick & easy.

how to force decimals to display in exponential notation

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?

thanks!
-rich evans

Oct 15 '06 #1
5 4908
re*****@cox.net wrote:
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?
http://msdn.microsoft.com/library/en...53e5d4ed66.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Oct 16 '06 #2
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
re*****@cox.net wrote:
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?

http://msdn.microsoft.com/library/en...53e5d4ed66.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Oct 16 '06 #3
re*****@cox.net wrote:
Hi Dave,

Thanks for the quick reply.

Isn't JScript a client-side scripting language?
No. JScript is a scripting language.
ASP support several scripting languages, including vbscript and jscript,
as well as others. See this for tips:
http://www.aspfaq.com/show.asp?id=2045

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.
I really need to be able to do this on the server-side.
...or did I misunderstand your solution?
Yes. He intended you to implement it in a server-side script block.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 16 '06 #4
re*****@cox.net wrote:
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?
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,
however.

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:

<%@Language=VBScript%><%

Randomize
Dim N : N = 100 * Rnd()
Response.Write(FormatEXP(N,10))

%>
<script runat="server" language="jscript">
function FormatEXP(n,d) {
return n.toExponential(d)
}
</script>

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Oct 16 '06 #5
perfect!
many thanks,

cheers!
- rich

Oct 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Timothy Fitz | last post: by
2 posts views Thread by SoLRaC | last post: by
8 posts views Thread by pereges | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.