Convert from scientific notation

Can someone help me with this? I cannot get this working even using some of the tips I found on this site and elsewhere:
Round this and format this with 2 decimals: '-2.58069E-11'.
Now I realize this would end up -2.58, but it is giving me an error instead.
Error converting data type varchar to numeric.
SELECT CAST('2.58069E-11' AS NUMERIC(24,2))
SELECT CAST('2.58069E-11' AS NUMERIC(24,12))
I tried 12 just to make sure that there was enough room for the decimals
If I use ISNUMERIC, it returns 1, so SQL Server considers it a number (at least with that function)
The next example works, but it is not what I want.
SELECT CAST('2.58069E-11' AS REAL) just returns the same thing with the 'E', (as REAL, of course)
In these example I haven't done the rounding yet.
I get all kinds of negative and positive numbers with different decimal lengths, but the scientific notation is particularly tricky.

Before I put this to bed, I have found out both the above solutions are wrong when using a regular decimal:
Try this:
SELECT CAST(CAST('-1131658.27' AS REAL) AS NUMERIC(24,2))
And this:
SELECT CAST(CONVERT(REAL, -1131658.27) as DECIMAL(24,12))
They both yield -1131658.25, and -1131658.250000000000, respectively.
This is probably some floating point error, but how do I take care of it?

Similar Messages

  • How to convert from scientific notations to double value ?

    Hi all,
    i need to convert a string 2E-23 to corresponding double values so that i can compare it one more existing double value. Is there any API present for this ?
    Thanks and regards,
    rosamama.

    Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.

  • Numeric Values Converted to Scientific Notation

    My BPEL process converts numeric values to scientific notation (eg. 12345678 is converted to 1.2345678E7). This then causes problems when I try to perform any mathematical operations on these values during an XSL transformation (output - NaN)
    Is there any way I can stop this data conversion?
    This occurs with BPEL 10.1.2.0.2. I'm loading the data from an Oracle 9.2 database using the DbAdapter.
    I've written an XSL routine to convert these values back to the correct decimal notation, but would prefer to stop this happening rather than workaround the problem.

    On further investigation, this occurs for values loaded from Oracle FLOAT database type.
    The XSD generated for the DbAdapter uses type xs:double for this field, but I've also tried changing this to xs:decimal & xs:float and still get the same problem.

  • Convert from Comma notation to Decimal Notation, Any FM ?

    Hi Experts,
    I am looking to convert from Europe format to US format for Quantity & amount fields, I mean
    e.g. Europe:  12.3456,78 -> US: 12,3456.78
    pls. i can not use offsetting, replace, pattern, overlay, concatenate etc.
    So, pls. let me know that, Is there any SAP FM for this purpose of DECIMAL NOTATION conversion?
    thanq
    Edited by: Srinivas on Feb 22, 2008 10:48 PM

    use.
    Replace all occurances of ',' in w_value with '.'.
    Check this thread.
    REgarding converting  ','  TO  '.'

  • Internal table data 1E2 automatically convert to scientific format

    Dear all,
    I have been searched for solution moths from the forums and tried all possible methods, but still no way to solve my above problem.  I found a way to solve it partially for us, but may be very helpful for others who meet similly case like mine, so I posted here.
    my problem is when I export my internal table data to Excel, the Cell data with 1E2 auto becomes 1.00E02, and 1E8 becomes 1.00E08, we need it to be 1E2 and 1E8 in excel.
    you can recreate my problem by
    1,  input 1E2 into your Microsoft Excel, then Enter, it will auto change into scientific format. which is we do not want.
    2, use any of your SAP system open any table as long as there is a Char (>3) field in that table. add some
    data entry in that field in the form "any amount (<15) of numeric 1 to 9"E"any one or two numeric 1 to 9". such as, 123E2, 1234E12 etc. then save this table's data to local file spread sheet, or use any FM to download it to a Excel file, when you open this
    file by Excel, the cell with above form will display as scientific. but
    if you put three or more numeric after the "E", such as 123E123 it will
    display correctly.
    what I have done:
    I searched in SCN for similar thread:
        Export to Excel 2007 - item number problem
        Exceding the limit of numbers in Excel at target side
        Excel download cell format problem
        Formating as Text in excel through SAP
        Converting of amount field into excel file through GUI DOWNLOAD
        Data downloaded to excel gets converted to exponential format.
        Problem with Excel download   and scientific number
        Re: Issue in displaying numbers in Excel?
        CSV Flat File Data Problem (Number converting to Scientific Notation)
    Tested accordingly, But none of these works in our case. because our
    ultimate receiver of email attachment will be external third party, we cannot ask
    them to change anything in their Excel.
    Search Microsoft help about Excel, http://support.microsoft.com/kb/214233,
    and it says this "Automatic Number Formatting" is a normal behaviour of excel.
    no way to turn it off, the "work-around" way that Microsoft provides is not suitable for our
    case.
    We test CL_iXML recently arrording to weblog http://wiki.sdn.sap.com/wiki/display/Snippets/FormattedExcelasEmailAttachment
    it successful controled the format. so this could be a solution for others whose internal table size is small. but our 2MB internal table bocome 6MB when converted to xml file attachment, which cannot be received by our end user's mail box. too big.
    So please advise your ideas.
    Many thanks in advance!
    Peter Ding
    Thank you very much for your time!

    Hi,
    You can achieve this by describing the spreadsheet in XML with the help of the DOM classes.
    The later releases of Excel can read and save spreadsheets as XML, providing your release supports this you can achieve it.
    Check out the following Wiki
    [Excel - XML|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/exporting%2bdata%2bto%2bexcel%2b-%2bxml%2bto%2bthe%2brescue]
    Regards,
    Darren

  • Scientific Notation when Downloading Reports

    When downloading reports from a web template, in either Excel or CSV, some values are getting converted to scientific notation in the downloaded file. I am wondering if there is a setting which prevents any data to be converted to scientific notation when downloading. The data appears to be fine when viewing the report in Web.

    Hi Ripel
    You have downloaded the file to CSV which is also excel based format and uses most of the Excel's features, and when data is CSV file is in scientic foirmat , same will come in notepad..just do one thing select the format as number in the csv file by selecting column...and save it...in csv/notepad you will now see actual value
    Thanks
    Tripple k

  • Float Data Value and Scientific Notation

    Hello All,
    SQL Server converts some of the float value into scientific notation for example 0.00001 will be stored as
    1E-05.
    Is there any simple method\formula\threshold to precisely tell when some particular value will be converted to scientific notation?
    Also I think oracle store same value above i.e. 0.00001 as it is with float data type but not the case with SQL Server. Any reason for the same?
    Thanks in Advance.
    -Malkesh

    Thanks Erland.
    I got your point that internal storage as you mentioned will be 53 bit and 11 bit exponent of 2. However my question remains the same that is there any method\threshold from which we can say that after this numeric value stored data will be represented in
    scientific notation or any rule of thumb? For example
    drop
    table #t
    CREATE
    TABLE #T (T1
    FLOAT)
    INSERT
    INTO #T (T1)
    SELECT 0.000001
    INSERT
    INTO #T (T1)
    SELECT 0.00001
    INSERT
    INTO #T (T1)
    SELECT 0.0001
    INSERT
    INTO #T (T1)
    SELECT 0.001
    INSERT
    INTO #T (T1)
    SELECT 0.01
    INSERT
    INTO #T (T1)
    SELECT 0.1
    INSERT
    INTO #T (T1)
    SELECT 1.
    INSERT
    INTO #T (T1)
    SELECT 1.0
    INSERT
    INTO #T (T1)
    SELECT 1.01
    INSERT
    INTO #T (T1)
    SELECT 1.001
    INSERT
    INTO #T (T1)
    SELECT 1.0001
    INSERT
    INTO #T (T1)
    SELECT 1.00001
    INSERT
    INTO #T (T1)
    SELECT 1.000001
    INSERT
    INTO #T (T1)
    SELECT 1.0000001
    INSERT
    INTO #T (T1)
    SELECT 1.00000001
    INSERT
    INTO #T (T1)
    SELECT 1.000000001
    INSERT
    INTO #T (T1)
    SELECT 1.0000000001
    INSERT
    INTO #T (T1)
    SELECT 1.00000000001
    INSERT
    INTO #T (T1)
    SELECT 1.000000000001
    INSERT
    INTO #T (T1)
    SELECT 1.1
    INSERT
    INTO #T (T1)
    SELECT 10.1
    INSERT
    INTO #T (T1)
    SELECT 100.1
    INSERT
    INTO #T (T1)
    SELECT 1000.1
    INSERT
    INTO #T (T1)
    SELECT 10000.1
    INSERT
    INTO #T (T1)
    SELECT 100000.1
    INSERT
    INTO #T (T1)
    SELECT 1000000.1
    INSERT
    INTO #T (T1)
    SELECT 10000000.1
    INSERT
    INTO #T (T1)
    SELECT 100000000.1
    INSERT
    INTO #T (T1)
    SELECT 1000000000.1
    INSERT
    INTO #T (T1)
    SELECT 10000000000.1
    INSERT
    INTO #T (T1)
    SELECT 100000000000.1
    INSERT
    INTO #T (T1)
    SELECT 1000000000000.1
    SELECT T1
    FROM #T
    Here you can see value < 0.0001 i.e. 0.00001 and 0.000001 both are in scientific notation. So which rule or formula drives this behavior that is what my question is. Sorry I am somewhat poor in mathematics fundamentals So if you can make it simple.
    Thanks Again.

  • Double in Scientific Notation after Marshal

    Hi,
    I have an element defined as an xsd:double. If I try and place a value say 100 into the element and then I marshal it I get an output of <Quantity>100.0</Quantity>... That is fine....
    However, if I put a value in of say 1000000000, I get an output of <Quantity>1.0E9</Quantity> when I marshal.
    Can I turn a setting on (or off) so the output does not get converted into scientific notation?
    -j

    I also verified the XML standard and you are right that the values are legal xsd:double values. What made this a problem for me is that the XSLT functions that use XPATH number() to process these values failed because XPATH specifies that a number is:
    Number ::= Digits ( '.' Digits?)? | '.' Digits
    which does not handle the exponents at all. So the XML documents produced could not be handled by XSLT processors.
    For fun, I redefined my schema definition to replace xsd:double with:
    <xs:simpleType name="simpleDouble">
         <xs:restriction base="xs:double">
              <xs:pattern value="(-)?[0-9]*(.[0-9]+)?" />
         </xs:restriction>
    </xs:simpleType>
    which is essentially a non-exponent based double. JAXB rendered the document, but then the validator complained that the output did not match the pattern. So JAXB does not use this pattern as a method of determining output, only as a method of validation.
    This is why I replaced the DoubleType class for my solution. The alternative of using the jaxb:globalBindings is probably a cleaner approach. I think I'll switch my implementation. Thanks for the pointer!
    -Allan

  • Long number in CSV file appearing in scientific notation by default

    Hi,
    How can I stop a long number in a CSV file that is opened in excel from appearing in scientific notation by default?
    eg.
    "hello","778002405501 ", "yes"
    becomes:
    hello | 7.78002E+11 | yes
    I have tried wrapping the data in quotes in the csv but to no avail.
    Thanks in advance,
    Alistair

    You can change the extension from ".csv" to ".xls" and use table to form the data and use
    style=”mso-number-format:\@;”
    Please read the sample code below in Classic ASP:
    You can also read in my blog http://sarbashish.wordpress.com/2012/11/30/export-to-excel-how-to-prevent-long-numbers-from-scientific-notation/
    <%
    Response.Clear
    Response.CacheControl = “no-cache”
    Response.AddHeader “Pragma”, “no-cache”
    Response.Expires = -1
    Response.ContentType = “application/vnd.ms-excel”
    Dim FileName
    FileName = “TestDB Lookup-” & month(now)&”-”&day(now)&”-”&year(now)&”.xls”
    Response.AddHeader “Content-Disposition”, “inline;filename=” & FileName
    %>
    <html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel” xmlns=”http://www.w3.org/TR/REC-html40″;>
    <head>
    <meta http-equiv=Content-Type content=”text/html; charset=UTF-8″>
    <!–[if gte mso 9]>
    <xml>
    <x:ExcelWorkbook>
    <x:ExcelWorksheet>
    <x:WorksheetOptions>
    <x:DisplayGridlines/>
    </x:WorksheetOptions>
    </x:ExcelWorksheet>
    </x:ExcelWorksheets>
    </x:ExcelWorkbook>
    </xml>
    <![endif]–>
    </head>
    <body>
    <table border=”0″>
    <tr>
    <td>ID</td>
    <td>Name</td>
    </tr>
    <tr>
    <td style=”mso-number-format:\@;”>01234567890123456567678788989909000030</td>
    <td>Sarbashish B</td>
    </tr>
    </table>
    </body>
    </html>
    Sarbashish Bhattacharjee http://sarbashish.wordpress.com

  • Converting from a double to scientific notation

    does anyone know how I can convert a double value to scientific notation?

    java.text.DecimalFormat can do that.

  • Converting scientific notation string to number?

    This is raising an error:
    > ToNumber (u201C2.75E-05u201D)
    How do you convert scientific notation strings to numbers?
    This is coming from XML. I can probably have the XML written so that it's not scientific notation.
    Tim

    Here's a not-so-pretty way:
    Local StringVar Array x;
    Local StringVar mantissa;
    Local StringVar exponent := "0";
    // Split into mantissa and exponent parts.
    x:= Split("24.2233E+2", "e", 2, 1);
    mantissa := x[1];
    If (UBound(x) = 2)
    Then
        exponent := x[2];
    // CDbl cannot interpret leading positive sign, so removie
    If Left(mantissa, 1) = "+"
    Then
        mantissa := Right(mantissa, Length(mantissa) - 1);
    If Left(exponent, 1) = "+"
    Then
        exponent := Right(exponent, Length(exponent) - 1);
    // Compute number
    CDbl(mantissa) * 10 ^ CDbl(exponent);
    Sincerely,
    Ted Ueda

  • Data retrieval in non-scientific notation from Netezza database

    Hi,
    I have a requirement where my BPEL service fetches data from Netezza database. In the database, there is a field which is of type numeric(16,8) and holds values say '0.00000000'. The select query on the table rerieves data in its scientific notation as '0E-8'.
    Please let me know how to retrieve its value in the form of non-scientific notation.
    Thanks in advance.
    Regards,
    Sitara

    hai
      chowdary,
       it is not possible to retrieve data from maintenace view.
    it is only possible to retrive data from a table or database
    / projection views defined ddic.
    Maintenace views are used to maintain data of an application object together.Data from several tables can be joined and summarized data can be seen of this view based on primary key join relationship using SM30.U make any changes  or view the data there only.
    if useful, reward points.
    By
    G.V.K.Prasad
    Edited by: PRASAD GVK on Apr 13, 2008 3:36 PM

  • Hello! I have some my violin recorded audio files and want them to be converted to printable notation throw "audio to score"from Factory. But do not have a normal result. Could someone help me, please. .

    I have some my violin recorded audio files and want them to be converted to printable notation throw "audio to score"from Factory. But do not have a normal result. Could someone help me, please. .

    seeren wrote:
    Normal result is on the sloppy side of inaccurate.
    Wish I'd started this topic so I could give you a green star!
    Great description.

  • Convert Scientific Notation to Float

    Hello
    How can we convert Scientific notation to float.
    e.g.
    1.23E-3(string) as  0.00123(float)
    Thanks
    Solved!
    Go to Solution.

    Use Fract/EngStringToNumber. Or ScanFromString with format %f…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Prevent large numbers from becoming scientific notation on CSV import

    Hi, I'm importing contacts in a .CSV file into iWork Numbers and it takes a 12-digit phone number from a guy in the UK and turns it into scientific notation. So something like 447729803988 becomes 4.4772E+11 which obviously loses some important digits. Is there a way to force Numbers to treat all fields as text on import so it doesn't drop this critical data? thanks
    Sean

    scrollin,
    Your digits are all there. Just format those cells to either Text or Number. Leading zeros do tend to get lost unless you pre-format to text. You can force the cell format to text on the fly by prefixing your input with a single-quote.
    Regards,
    Jerry

Maybe you are looking for

  • Mountain Lion Mail not syncing with iCloud

    I have a gmail, yahoo mail, microsoft exchange, and apple email account.  I can get all of them to sync on my iPhone, iPad, and iMac.  However, for some reason only the Apple email shows up on iCloud.  I deleted my account and signed out of iCloud on

  • Need help in sending FAX

    Hi, Im sending an email/fax  from sales order/delivery/billing. Once I run it, it is getting updated in SOST transaction. For Email in SOST, the docuemnt title is correctly displaying. But for telefax, the document title is showing differntly.(like R

  • Problem with field length

    Hi all, I'm using multiple select option list, and now I'm getting this error when check in a file: Content Server Request Failed Content item 'mohe_000934' was not successfully checked in. The value entered for 'Dokumen' exceeds 30 characters, the m

  • Like to Create PDF that includes portrait & Landscape pages

    I have a HP Scanner which allows me to create PDF documents. I have these very important documents about "My Learning Disability" the issue is that some pages are printed in Portrait and others are in Landscape. I really need to know if its possible

  • Call cffunction in cfc file

    Hi, I have a cfm file and cfc file and want to implement some checking function in cfc file like following: In cfm file, I use javascript to call cfc function where result is a cfdiv tag in cfm file: 1) ColdFusion.navigate( 'cfc/control.cfc?method=ch