Scientific Notation for Calculator

Hello All
I am working on a calculator project and am trying to format the results of my calculations so that it displays just like the Windows calculator, eg. 99999999999999999999999999999999 * 9 should be = 8.9999999999999999999999999999999e+32.
My calculations are done using BigDecimal (for precision reasons) and my result needs to be a String (for display).
Can anyone please tell me how I can format the results of the following calculation:
BigDecimal num1=new java.math.BigDecimal("99999999999999999999999999999999");
BigDecimal num2=new java.math.BigDecimal("9");
BigDecimal numRes=new java.math.BigDecimal("0");
numRes = num1.multiply(num2);
After the calculation i need the result in a String.
Thanks!

Not AFAIK. It's retaining the place holders of the largest number: basically, computing, 1000/3=333.333.

Similar Messages

  • Scientific notation doesn't display correctly

    Hi, this is just a general question but it's about the Calculator app. The problem is with displaying answers in scientific notation. When I'm in scientific calculator mode, answers displayed on the screen only appear in scientific notation when they are larger than the number of digits that can be displayed. However, whenever I use it to calculate something in which the answer is smaller than the set precision for the number of decimal places, it always gives 0 instead of scientific notation. For example, if I type a number such as 1E19 and press =, then the answer displays correctly as 1E19. However, if I type 1/1E19, and press =, then the answer simply shows up as 0 instead of 1E-19, which is the correct answer in scientific notation. So, it seems that the scientific notation in Calculator simply does not display negative exponents in the scientific notation (I know that I can type such numbers but for some reason, it cannot display them as answers). This is very annoying because I often work with very small numbers, not just very large ones. Is there any way that I can get the scientific notation to display negative exponents when I'm working with very small numbers and when the answer is smaller than the set number of decimal places?

    There are tonnes of possibilities and many websites with suggestions. I tried all sorts of these option (clear cache, clear cookies, anti-virus changes, page style options etc) with no success until eventually I accidentally changed my character encoding autodetect (firefox 6) from "off" to "universal" and everything is fine.

  • 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.

  • Calculator: removing scientific notation in results?

    This seems like it must be a bug or a corrupted app, but I'd just like to confirm: with the calculator in "basic" mode, dividing two numbers which only have one significant digit returns a result like so: 1/3000 = 0.000333 (the setting for decimal places seems to be irrelevant).
    However, changing either number to have more than one significant digit returns the result in scientific notation, like so: 1/3100 = 3.225806e-04.
    Can anyone else duplicate this or help me correct it? It's obnoxious to have to keep adjusting the numbers. And yes, I realize that means my math skills suck. Thanks in advance.

    Bumpty-bump. Can anyone at least confirm or deny? TIA.

  • Calculator.app Version 4.5.3 (99.2) and Scientific Notation

    I want to enter a number with scientific notation.
    2.71e1 doesn't return 27.1, but rather 0.999...
    It seems that Calculator.app is dividing by e.
    This is not a common operation.
    2.71E1 gives 27.1great! But ...
    2.71E-1 does not return 0.271 neither does
    2.71E(-1)
    I have yet to figure out how to use negative exponents in Scientific notation.
    This seems to be a bug in Calculator.app Version 4.5.3 (99.2)

    All my spaces were deleted.
    Take two.
    My input ======= Calculator
    2 ============ 2
    2. ============ 2.
    2.7 =========== 2.7
    2.7E ========== 2.7 E 0
    2.7E- ========== 2.7 (and the small - subscript indicating a negative number)
    2.7E-1 ========= 1 (and the small - subscript indicating a negative number)
    Now hitting enter === 1.7 (it appears to have subtracted 1 from 2.7)
    Do our version of Calculator match?
    Thanks for being interested.

  • Preventing automatic scientific notation conversion for excel o/p of bi pub

    I have a column in a query that contains a mixture of numbers and letters and hyphens. If the only letter is E, then I get scientific notation instead of the actual text,when I run the report for excel output and open it in excel.
    For example:
    185701E-02 becomes 1.86E+03 in the excel output of the report
    4962E6 becomes 4.96E+09
    will be really grateful if anyone can help

    See this thread:
    Re: Long account Numbers displayed in exponential form in excel using XML Pub
    Regards,
    Dave

  • Create an NSString for number in scientific notation from double?

    Hi
    Given a double, I want to create a string in scientific notation.
    e.g for a double with a value of 123.456, I want the NSString to be "1.23456e+2" for entering in to a UITextField.
    I've looked through the docs but can't find a formatter. (There is mention of "%a" being scientific format, but it produces hex output.)
    Thanks for any clues.
    Steve

    Here, you should find what you are looking for:
    http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Ar ticles/FormatStrings.html#//apple_ref/doc/uid/20000943
    http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Ar ticles/FormatStrings.html#//apple_ref/doc/uid/20000943
    http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/ Classes/NSStringClass/Reference/NSString.html#//appleref/occ/clm/NSString/stringWithFormat:

  • Calculator and Scientific Notation

    My Calculator App seems to randomly switch back to scientific notation instead of displaying results in regular x.xx format.
    I tried deleting the com.apple.calculator.plist file and then relaunching Calculator but that didn't work.
    Any other suggestions on how to get the calculator app back to displaying results in normal (non-scientific notation) mode?
    thanks

    Then, I'm at a loss. Mine only shows scientific notation when the value exceeds whatever's set as the number's max range. You might want to peruse Calculator's help files.

  • Preventing automatic scientific notation conversion for excel output?

    I have a column in a report that contains a mixture of numbers and letters and hyphens. If the only letter is E, then I get scientific notation instead of the actual text when I run the report for excel output and open it in excel.
    For example:
    185701E-02 becomes 1.86E+03
    4962E6 becomes 4.96E+09
    Any ideas how to fix or work around this in the template, data definition, or excel config?
    Thanks,
    Kevin

    I tried pre-pending an apostrophe in the SQL and in the rtf template to indicate to excel that it is a text field, but this just resulted (not surprisingly) in '185701E-02 instead of 185701E-02

  • Remove scientific notation in report

    I'm calculating a number and placing it in a comment box on a report. This works fine, but one of the numbers has decided to display in scientific notation (1.52666667e-3). The problem is that the comment box is not large enough to display the scientific notation and gives no indication of not fitting into the box. Instead I see 1.52666 with no indication of the exponent. I'd much rather see .001527 however I don't want to force a STR format with "d.dddddd" because most numbers don't need this much precision and I'd probably run into errors for numbers such as 12345 which won't fit into the comment box with forced 6 digit precision. If I can force it out of scientific precision, it'll probably be fine.
    BTW: is there a certain number range where scientific notation becomes the default? If I knew this range I could then force the format with the STR function to display the way I want. e.g. IF x>-001 and x<.001 then STR(X,"d.dddd")
    Either method would probably work for me.
    thanks,
    James
    Solved!
    Go to Solution.

    MyVar is a 2 dimensional pointer (Channel Group, Channel) to numeric channels that meet some criteria.
    change box size: I had to make the box 3 times the width to display the number correctly. It shows 1.27933333333333E-03*. I'm appending the "*" to show the field is calculated instead of unadultered from the .csv. Maybe the problem isn't that the number is small, but that it's infinitely repeating. The number is calculate from the values .001919 - abs(.001919)/3
    Left Justify: no difference from right justify.
    Autoadj: shows 1.28E-
    I'm making a column of channels on the report, that's why the comment text is being set multiple times.
    Humphreyy - thanks for your ideas and help.

  • Scientific Notation in Java

    Hi,
    In the hopes of enforcing a precision of 1.0e-16 for all the doubles in my Java application, I am trying
    to apply a DecimalFormat pattern so that my doubles can be printed in scientific notation if necessary. I am doing:
    DecimalFormat decf = (DecimalFormat)DecimalFormat.getInstance();
    decf.applyPattern("0.################E0");
    as the first step in the execution process but this is not working. Am I missing something?
    Thanks,
    Corrine

    It might help if you explained what "not working" means in this case. You can only use formatting to control how the numbers appear to you, not how they are represented internally for calculation, if that's part of your question.

  • Double.parseDouble(String) - problems when string is in scientific notation

    Hello guys,
    I'm doing some numerical calculations and I wonder whether it is possible for Double.parseDouble(String) to parse string in the scientific notation i.e. 1.0824234234E-10. Is it the notation itself causing the exception : NumberFormatException or the number is just too big/small and double can't hold it ?
    If it's just the notation how can I fix it ?
    Regards

    i'm not quite sure whether double odoes not allow it.
    perhaps consider the api Double.valueOf() and the testing code provided; reproduced below:To avoid calling this method on a invalid string and having a NumberFormatException be thrown, the regular expression below can be used to screen the input string:
            final String Digits     = "(\\p{Digit}+)";
      final String HexDigits  = "(\\p{XDigit}+)";
            // an exponent is 'e' or 'E' followed by an optionally
            // signed decimal integer.
            final String Exp        = "[eE][+-]?"+Digits;
            final String fpRegex    =
                ("[\\x00-\\x20]*"+  // Optional leading "whitespace"
                 "[+-]?(" + // Optional sign character
                 "NaN|" +           // "NaN" string
                 "Infinity|" +      // "Infinity" string
                 // A decimal floating-point string representing a finite positive
                 // number without a leading sign has at most five basic pieces:
                 // Digits . Digits ExponentPart FloatTypeSuffix
                 // Since this method allows integer-only strings as input
                 // in addition to strings of floating-point literals, the
                 // two sub-patterns below are simplifications of the grammar
                 // productions from the Java Language Specification, 2nd
                 // edition, section 3.10.2.
                 // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
                 "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
                 // . Digits ExponentPart_opt FloatTypeSuffix_opt
                 "(\\.("+Digits+")("+Exp+")?)|"+
           // Hexadecimal strings
           "((" +
            // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
            "(0[xX]" + HexDigits + "(\\.)?)|" +
            // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
            "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
            ")[pP][+-]?" + Digits + "))" +
                 "[fFdD]?))" +
                 "[\\x00-\\x20]*");// Optional trailing "whitespace"
      if (Pattern.matches(fpRegex, myString))
                Double.valueOf(myString); // Will not throw NumberFormatException
            else {
                // Perform suitable alternative action
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html

  • Int printing out as scientific notation

    maybe doing something stupid here but I can't seem to pick it up.
    I have a Window that calls a subclass to display a calculator, and then returns the final value to the Window, if I input 10 digits it prints on as a 12345678E5
    something like that.
    Anywho here's the two methods that deal with value in the subclass( calculator )
    public int ReturnNumber(){//the method that will return the value from the keyboard
       int final_number = Integer.parseInt(number); 
        return final_number;   // returns value to question screen
      private void NextButtonActionPerformed (java.awt.event.ActionEvent evt) {
       if ( value.length() != allowable_answers[currentQuestionNumber] ){
                     JOptionPane.showMessageDialog(this, "Please make a valid entry.", "Invalid",
                     JOptionPane.WARNING_MESSAGE );
                     value.replace(0,counter,""); 
                     jTextField1.setText( null );
                     return;
        else {
                number = value.toString();
               setVisible(false);
               frame.final_number = ReturnNumber();
               frame.userMakeSelection = true;
               frame.FinalTimer.start();
               frame.ButtonSelected();Code from window that deals with the number
    if(Numeric[currentQuestionNumber]){
                currentAnswers[currentQuestionNumber][1] = final_number;// currentAnswers is a float[][]
                numeric_question_value[currentQuestionNumber][0] = final_number;// used in poll frequency
              }// numeric is a int[]
            else
                currentAnswers[currentQuestionNumber][currentChoice] = currentChoice;Is from trying to jam an int into float?
    Any suggestions
    Jim

    Is from trying to jam an int into float?That's exactly the cause. Here are some solutions:
    - Use java.text.DecimalFormat to format the output or cast the float to an integer type when you want to print it (presicion might become a problem).
    - Keep the number in an int or long all the time. This way you'll not lose any presicion.
    Explanation can be found in the API docs of Float.toString():"If the argument is NaN, the result is the string "NaN".
    Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument. If the sign is negative, the first character of the result is '-' ('-'); if the sign is positive, no sign character appears in the result. As for the magnitude m:
    If m is less than 10^-3 or not less than 10^7, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10n<=m<1; then let a be the mathematically exact quotient of m and 10n so that 1<a<10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.' (.), followed by decimal digits representing the fractional part of a, followed by the letter 'E' (E), followed by a representation of n as a decimal integer, as produced by the method Integer.toString(int) of one argument."

  • Scientific display in Calculator?

    Is there anyway to have the display show scientific notation?  If the number is less than the number of digits shown it just shows 0.  As soon as you enter another number and the current number goes on the stack (in RPN lingo)  it is shown in scientific notation.  On HP calculators you can have the display use Fix, Sci, and Eng.     The Decimal Places . . .   command under View is only for Fix  type display, anyway to set Sci for the display?

    X423424X,
    Thanks for trying to be helpful.  I well aware of nonpareil, which used to have a bug where you had to turn on the 15c, then off, then back on.  If I am going to do anything major, I don't use a calculator, so I don't need anything fancy, the Apple calculator fills the bill.  Another item is that Apple's shows the 4 elements of the stack, which is nice, instead of the 'realist' HP look alikes (and PCalc too).
    Paul

  • Select Query resulting in Scientific Notation

    Hello all,
    I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
    select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
    I apologize in advance if this has been answered already.
    Thanks!

    >
    When the extractor finishes, it returns the data into a flat file.
    don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
    >
    Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
    Here is how sql*plus (Oracle's tool) will display the data using default settings
    SQL> select 12345678901234567890123456789012345678 no_format,
      2  to_char(12345678901234567890123456789012345678, '99999999999999999999999999
    999999999999') with_format
      3   from dual;
    NO_FORMAT WITH_FORMAT
    1.2346E+37  12345678901234567890123456789012345678
    SQL>
    ----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
    NO_FORMAT,WITH_FORMAT
    1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string.

Maybe you are looking for