473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 5061
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryoga | last post by:
How can I print out the value of a large double in plain decimal form without the exponential notation? For example (quick code): PlainPrint.java: --------------- public class PlainPrint {...
4
by: Timothy Fitz | last post by:
Why are all numberical literals in exponential notation floats? To me it is counter-intuitive for 1e3 to behave so fundamentally different from 1000. Timothy Fitz
2
by: SoLRaC | last post by:
I have a form, and i want with javascript round a number with 2 decimals to de uper next 0 or five. IE if you have the number 4,53 it must be rounded to 4,55. Until now i wrote that var valor...
9
by: J.Sperlhofer | last post by:
Good morning, Javascript-Professionals. I'm looking for an possibility to show a (calculated) 64bit-Number without exponential notation. I don't want to see exponational notation within my...
2
by: rSmoke | last post by:
I have a DataSet that contains a table with about 6 columns of high accuracy decimal values. When I try to write out the DataSet using the WriteXML() function the XML is written fine, but the...
3
by: JDC | last post by:
Hi all, Is there a recommended way (i.e. not a bodge) to get a GridView to always display decimal numbers using a dot as the decimal separator, regardless of the locale the user is viewing the...
4
by: Jaash | last post by:
I have a graph within a report (simply built with the Chart Wizard). However when my source data set falls to a lower set of numbers ... the Y-Axis will display 0, 0.5, 1, 1.5, etc. Is there a...
4
by: b4ukiran | last post by:
Hi all, I have a requirement to print large double values without the exponential notaion. The double value can be a declared variable or any calculated value within the code. In any case, I...
8
by: pereges | last post by:
Hi, can anyone please tell me what is wrong in this program and why does it keep givng nan as the output(eg. take input as 1.2e+10) ? #include <stdio.h> #define PLANCK 6.626068e10-34 int...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.