WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Number Conversion

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Floating Point Scientific Notation


Question:

I had WinBatch perform some math on a file and create a new array[x]. In the final results I noticed that most of the results were displayed as a regular floating point number (e.g. 0.00399435) and every now and then the result was displayed in scientific notation (e.g. -6.12070021e-005).

It seems that WinBatch can read scientific notation as I did some preliminary tests, but I was wondering:

1) At what level of precision does WinBatch decide to use Scientific Notation instead of Floating Point?

2) Does WinBatch always identify floating point numbers simply because of the 'e'? Do I need to do anything different when I am mixing floating point numbers with scientific notation numbers?

Answer:

1) At what level of precision does WinBatch decide to use Scientific Notation instead of Floating Point?

If the absolute (positive or negative) value is larger than 999999999 or smaller than 0.0001, or if Decimals(-3) is used.

2) Does WinBatch always identify floating point numbers simply because of the 'e'? Do I need to do anything different when I am mixing floating point numbers with scientific notation numbers?

An 'e' (or 'E') signals a scientific notation number. Otherwise, a decimal point signals a regular floating point number.

Here is a cute sample script. It shows the Decimals function at the same time



a=ArrDimension(100)

For dd = -4 To 3
   
   If dd == -4
      ddx="default"
   Else
      ddx=dd
      Decimals(dd)
   EndIf
   
   
   a[0]  = 400000000000001.00
   a[1]  = 50000000000001.00
   a[2]  = 6000000000001.00
   a[3]  = 700000000001.00
   a[4]  = 80000000001.00
   a[5]  = 9000000001.00
   a[6]  = 100000001.000
   a[7]  = 20000001.000
   a[8]  = 3000001.000
   a[9]  = 400001.000
   a[10] = 50001.000
   a[11] = 6001.000
   a[12] = 701.000
   a[13] = 81.000
   a[14] = 9.000
   
   a[15] = 1.1
   a[16] = 2.01
   a[17] = 3.001
   a[18] = 4.0001
   a[19] = 5.00001
   a[20] = 6.000001
   a[21] = 7.0000001
   a[22] = 8.00000001
   a[23] = 9.000000001
   a[24] = 8.0000000001
   a[25] = 0.1
   a[26] = 0.02
   a[27] = 0.003
   a[28] = 0.0004
   a[29] = 0.00005
   a[30] = 0.000006
   a[31] = 0.0000007
   a[32] = 0.00000008
   a[33] = 0.000000009

   list=""
   For zz=0 To 33
      list=StrCat(list,@CRLF,zz,@TAB,a[zz])
   Next
Message("Results of Decimals %ddx%",list)

Next
-------------------------------------------------------------------------------- Post New Topic | Reply to: "Re: Scientific Notation"
Article ID:   W16549
File Created: 2005:02:18:12:21:24
Last Updated: 2005:02:18:12:21:24