RE: H e l p with some vbscript

by Stephen Johnston <pepe(at)gainsay.com>

 Date:  Wed, 02 Aug 2000 00:37:02 -0400
 To:  Doug Miles <dmiles(at)ntsllc.com>,
hwg-techniques(at)hwg.org
 In-Reply-To: 
  todo: View Thread, Original
Doug-

         Thanks alot for the input, the code I posted was one of many 
variations I had played with. The real problem is that I am duplicating an 
algorithm, from Delphi 3 (Object Pascal), which uses two digits to the 
right of the resulting number for one thing and the two digits to the left 
for another. The algorithm is effective for what we need and has been used 
for a few years in the Pascal program, now the VBScript conversion is 
ticking me off.
         I was hoping to get at the 'E' value so that maybe I could fake it 
with a text string. That way once I had the 'E' value I could just turn the 
number into a string, rip out the decimal, place the correct number of 
zeros and place the decimal again. The problem is really only with small 
numerators right now, which do not occur too frequently in the algorithm. 
However I can't be so shortsighted since the denominator *could* be 
changed, conceivably, and that is in the spec for the algorithm.
         Anyway, I hope that clarifies the problem for you, or someone else 
out there.

Thanks Again-
Stephen

At 07:37 PM 8/1/2000, you wrote:
>Hi Stephen,
>
>If this number is going to be used in subsequent mathematical statements,
>there is no need to do any conversion.  VBScript will display it in E
>notation which appears to cause problems, but internally the variable is
>just a number.  If you were to follow the code you have with:
>    Response.Write fltResult * 1000 & "<br />"
>you would see the number  15.8730158730159 , evidence that the variable does
>still work for math operations.
>
>If the issue is that you have too many digits of precision after the decimal
>(which is why VBScript put it in E notation), you could truncate some digits
>by doing something like:
>    fltResult = CInt(fltResult*100000)/100000
>which changes the number to 0.01587.
>
>Be sure to consider the precision of the results you really need.  Perhaps
>CSng() would be better than CDbl.  Also, you only need to use the convert
>functions (csng or cdbl) if the number is of a very dissimilar type (like a
>string).  Normally, you could just write:
>    value = 63
>    custnum = 1
>    fltResult = custnum / value
>It doesn't change the outcome (unless you need high precision) but it is
>much easier to read the code.
>
>Hope this helps.  Contact me if you need more.
>
>--Doug
>
> > -----Original Message-----
> > From: owner-hwg-techniques(at)hwg.org
> > [mailto:owner-hwg-techniques(at)hwg.org]On Behalf Of Stephen Johnston
> > Sent: Tuesday, August 01, 2000 9:37 AM
> > To: hwg-techniques(at)hwg.org
> > Subject: H e l p with some vbscript
> >
> >
> > Hello Group-
> >
> >       Can someone help me with this piece of VBScript?
> >
> > ******** CODE *********
> >
> >       value = 63
> >       custnum = 1
> >       fltResult = CDbl(CDbl(custnum) / CDbl(value))
> >       Response.Write(value & "<br>")
> >       Response.Write(custnum & "<br>")
> >       Response.Write(CDbl(fltResult) & "<br>")
> >
> > ***********************
> >
> >       What i get is:
> >       63
> >       1
> >       1.58730158730159E-02
> >
> >       Anyone got any ideas how return the value without the
> > scientific notation?
> > Or a way to get at the 'E' value?
> >
> > Thanks-
> > Stephen Johnston
> >

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA