Float arithmetic operation error

hello,
When I run the following code :
public class a{
public static void main(String args[])
float f=0,w=0.01f;
for(int i=0;i<200;i++)
f = f+w;
System.out.print(" "+f);
II encountered with the following output
0.01 0.02 0.03 0.04 0.049999997 0.059999995 0.06999999 0.07999999 0.08999999
09999999 0.109999985 0.11999998 0.12999998 0.13999999 0.14999999 0.16 0.17 0.1
0.19000001 0.20000002 0.21000002 0.22000003 0.23000003 0.24000004 0.25000003 0
6000002 0.27 0.28 0.29 0.29999998 0.30999997 0.31999996 0.32999995 0.33999994
34999993 0.35999992 0.36999992 0.3799999 0.3899999 0.3999999 0.40999988 0.4199
87 0.42999986 0.43999985 0.44999984 0.45999983 0.46999982 0.4799998 0.4899998
4999998 0.5099998 0.5199998 0.5299998 0.5399998 0.5499998 0.55999976 0.5699997
0.57999974 0.58999974 0.5999997 0.6099997 0.6199997 0.6299997 0.6399997 0.6499
7 0.65999967 0.66999966 0.67999965 0.68999964 0.69999963 0.7099996 0.7199996 0
299996 0.7399996 0.7499996 0.7599996 0.76999956 0.77999955 0.78999954 0.799999
0.8099995 0.8199995 0.8299995 0.8399995 0.8499995 0.8599995 0.86999947 0.8799
46 0.88999945 0.89999944 0.90999943 0.9199994 0.9299994 0.9399994 0.9499994 0.
99994 0.9699994 0.97999936 0.98999935 0.99999934 1.0099994 1.0199994 1.0299994
.0399994 1.0499994 1.0599993 1.0699993 1.0799993 1.0899993 1.0999993 1.1099993
.1199993 1.1299993 1.1399993 1.1499993 1.1599993 1.1699992 1.1799992 1.1899992
.1999992 1.2099992 1.2199992 1.2299992 1.2399992 1.2499992 1.2599992 1.2699991
.2799991 1.2899991 1.2999991 1.3099991 1.3199991 1.3299991 1.3399991 1.3499991
.3599991 1.369999 1.379999 1.389999 1.399999 1.409999 1.419999 1.429999 1.4399
1.449999 1.459999 1.469999 1.479999 1.4899989 1.4999989 1.5099989 1.5199989 1
299989 1.5399989 1.5499989 1.5599989 1.5699989 1.5799989 1.5899988 1.5999988 1
099988 1.6199988 1.6299988 1.6399988 1.6499988 1.6599988 1.6699988 1.6799988 1
899987 1.6999987 1.7099987 1.7199987 1.7299987 1.7399987 1.7499987 1.7599987 1
699987 1.7799987 1.7899987 1.7999986 1.8099986 1.8199986 1.8299986 1.8399986 1
499986 1.8599986 1.8699986 1.8799986 1.8899986 1.8999985 1.9099985 1.9199985 1
299985 1.9399985 1.9499985 1.9599985 1.9699985 1.9799985 1.9899985 1.9999985
My question is where did 0.049999997 comes from as I only add 0.01 at each time.
Anyone can help??

Because the programmers working there are highly
educated so it's not likely.Oh, you know all of them and are familiar with their
educational backgrounds? I had no idea there wereno
undereducated programmers in Bangalore.Tragic! Listen to the winings of a sorry programmer in
denial used to have everything served on a silver
plate without any real effort.Where in the hell is this coming from? Are you really that stupid, or are you just deliberately trying to push people's buttons? I'm betting on, and hoping for, the second.

Similar Messages

  • Error while doing MIRO-Overflow for arithmetical operation (type P) in prog

    Hi ,
    I am getting the error while doing the MIRO  as below-
    Runtime Errors         COMPUTE_BCD_OVERFLOW
    Exception              CX_SY_ARITHMETIC_OVERFLOW
    Date and Time          20.05.2009 10:07:03
    Short text
         Overflow during the arithmetical operation (type P) in program "SAPLMRMC".
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLMRMC" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    Error analysis
         An exception occurred that is explained in detail below.
         The exception, which is assigned to class 'CX_SY_ARITHMETIC_OVERFLOW', was not
          caught in
         procedure "MRM_AMOUNT_QUANTITY_PROPOSE" "(FUNCTION)", nor was it propagated by
          a RAISING clause.
         Since the caller of the procedure could not have anticipated that the
    Please let me know how can this be removed.

    Hi,
    There can be some problem with tolerances set in the customizing.
    In my case, I was getting this error because of delivery date variance. The difference between delivery date maintained in PO and invoice date was huge and hence the multiplication of price of PO and difference  of delivery date was huge and that was the reason for error.
    Similarly in your case also, there will be some tolerance limit problem.
    Please check your tolerance limits set in customizing.
    Regards,
    Mihir Popat

  • Power query from ODBC :"DataSource.Error: Arithmetic operation resulted in an overflow"

    Good day
    Everytime I want to pull data into a query from our servers it gives the error "DataSource.Error: Arithmetic operation resulted in an overflow". What is the reason for this error, and how do I get past this bump.
    Thanks in advance
    Arnoux

    Hey Tristan. Thanks I did that yes.
    For some reason my direct MySQL connection does not want to work.
    I get the following error
    DataSource.Error: MySQL: Unable to find a database provider with invariant name 'MySql.Data.MySqlClient'.
    This error may have been the result of provider-specific client software being required but missing on this computer.  To download client software for this provider, visit the following site and choose at minimum 'MySQL Connector/Net':

  • Process chain error:Error in an arithmetic operation in record

    Hi friends ,
    Plz help me ehow to solve the  error: Error in an arithmetic operation in record  in process chains  when loading IP.
    Error in  error messages s:
    Record 1927 :Contents 1100.00 J from field PSWBT cannot be converted in type CURR -
    Record 1927 :Contents 0.00 0 from field BDIF2 cannot be converted in type CURR
    Record 1927 :Contents 0.00 0 from field FDWBT cannot be converted in type CURR -
       what can i do ?
    regards ,
    Pavan

    Hi pawan,
    If you are loading data thru PSA, correct these values in the PSA and reload it again. Best solution would be to correct it in the source system also. If you see the record 1927 in your case has following values for the fields.
    PSWBT - 1100.00 J
    BDIF - 0.00 0
    FDWBT - 0.00 0
    You can see the spaces in between as well as the character 'J'.
    Hence it is giving you this error.
    Correct it in PSA and reload it.
    it will go fine...
    Regards.

  • Arithmetic Overflow error converting float to data type numeric

    Hi,
    Am facing strange issue,I have function which returns money datatype and assigning the return money value to float datatype in table.
    Error msg:
    Msg 8115, Level 16, State 6, Procedure GBCalcCatalogPriceNewV2, Line 204
    Arithmetic overflow error converting float to data type numeric.
    The statement has been terminated.
    Strange thing is the same stored procedure is working fine in production environment,but in the deveopment i see this error.Am scared if the same happens in the production environment.Please advice and advance
    thanks
    Regards
    RAj

    Strange thing is the same stored procedure is working fine in production environment,
    How could that be strange? This is an error that occurs depending on the data. Accidents that are waiting to happen will happen sooner or later.
    Then again, a development database may be more prone to such errors, because data that entered are completely out of whack with real life data. Still it is a warning sign. If you have some place where you convert data from float to numeric, you must consider
    the risk that the float value is outside the range for the numeric data type. How do you prevent that from happening? Maybe a CHECK constraint on the column? Of if the data origins from a money column, use a numeric data type with sufficient precision.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Error in arithmetic operation

    All,
    I have the error when loading my data, "error in arithmetic operation".
    I am trying to load e.g.:
    20030412101100 in a DATS field.
    My question:
    <b>How can I remove the 6 digits from the right in my transferstructure?</b>
    Please guide in steps if possible,
    Many thanks!
    Andrew

    Hi dear,
    You can also try SUBSTRING:
    Cut out part of a character string.
    Parameters
    SUBSTRING( <character string>, <offset>, <length> )
    Result
    Part of a character string
    Example
    SUBSTRING( 'ABCD', 0, 3 ) = 'ABC'
    SUBSTRING( 'ABCD', 2, 2 ) = 'CD'
    Hope it help...

  • Error in arithmetic operation in record

    Hi all
    when I'm loading from flat file i'm getting the following error
    "Error in arithmetic operation in record"
    Also one more error is
    "Error 8" error
    Pl reply with solution asap
    Thanks and Regards
    Shyam

    Hi Shyam,
    Delete Infosource - Source system assignment (with PSA tables etc.).
    Then save (activate) the Infosource (communication structure).
    Then assign source system, create infopackage and load data again.
    Should work fine then.
    Sham'm

  • Qosmio F50 - Webcam error - Invalid floating point operation

    Hi
    I have Qosmio F50 (4 Weeks old) problem is after two weeks webcam has stopped working *Invalid floating point operation*
    I have to close program via task manager, *Camera assistant software not responding*.
    Have tried following.
    Update all drivers, system restore
    Toshiba help line after all efforts suggested complete reinstall this is to aggressive for me as it would loose certain software on laptop that I had to transfer from old PC and had to plead with certain software companies to transfer (only one license etc).
    Has anybody else had this problem and is there a simple solution
    Will

    Hi,
    I have the same problem, Laptop Qosmio F50 is 4 weeks old and now the webcam stopped working.... it's quite annoying, whenever I start the application it says ' Invalid floating point operation'. To me this sounds as some issues in the software and the compatibility on vista, I think it could happen after putting the laptop to hibernate or suspension state and then when it comes back, the webcam stops working. so let's see if toshiba realeases a fix or new version quickly, otherwise I would be quite disspointed with such a good laptop.

  • Error - "Invalid floating point operation"

    I keep getting a message that says "invalid floating point operation" and the files that I am trying to read are scrambled.  They used to be ok.  Please advise....

    Hi,
    I have the same problem, Laptop Qosmio F50 is 4 weeks old and now the webcam stopped working.... it's quite annoying, whenever I start the application it says ' Invalid floating point operation'. To me this sounds as some issues in the software and the compatibility on vista, I think it could happen after putting the laptop to hibernate or suspension state and then when it comes back, the webcam stops working. so let's see if toshiba realeases a fix or new version quickly, otherwise I would be quite disspointed with such a good laptop.

  • Question in floating point operation

    Hi,
    I have question in java floating point operation.
    public class test
         public static void main(String args[])
              double d1 = 243.35 ;
              double d2 = 2.3 ;
              System.out.println(d1 * d2) ;
              System.out.println((float)d1 * (float)d2) ;
    The result is,
    java version "1.4.1_02"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
    Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
    5.597049999999999E8
    5.5970502E8
    Though the multiplication does not result irrational number like 1/3, the result of the first statement is not accurate enough. In our project, this multiplication involves with money and we cannot ignore this.
    Can anyone suggest why this is happening? Do I need to convert all the numbers to float to avoid this...Or Is it a bug?
    ~ Sathiya Dhanapal.

    The underlying problem is that not all numbers can be represented exactly in a floating point representation. But if you perform all calculations using doubles and then round to two fractional digits at the end you should get a "correct" result UNLESS you have used ill-conditioned formulas introducing other kinds of arithmetic errors.
    There's another way around this when it comes to counting money and that's to use integers (long or int). You convert every number to the lowest monetary unit (like a cent or whatever). Every money-amount can now be represented exactly but you still have to be careful because the rounding problem is still there (What do you do with the last cent when you split 100 cents in 3).
    In your example the "more correct" you've got from using floats instead of doubles is only an illusion. The result has been implictly rounded becasuse fewer bits have been used. If you round the double result to the same precision as the float result, they're the same.
    The important lesson in all this is TO KNOW WHEN TO ROUND.

  • ODBC BI Server Bug - arithmetic operation resulted in an overflow

    I am trying to write some really simple .NET code access the Oracle BI Server ODBC driver and it's not working at all.  I've connected fine, however it seems like anything I try to do related to getting database information spits up an error "arithmetic operation resulted in an overflow".
    Here is the code:
    Dim ConnectString As String
    Dim FactoryType As String
    Dim Factory As System.Data.Common.DbProviderFactory
    Dim Connection As System.Data.Common.DbConnection = Nothing
    Dim TablesData As System.Data.DataTable = Nothing
    Dim err As String = ""
    Dim nl As String = Chr(13) + Chr(10)
    Try
        ' Connect to the database via ODBC
        ConnectString = "DSN=BSODBC_7;uid=TheUser10;pwd=************"
        FactoryType = "System.Data.Odbc"
        Factory = System.Data.Common.DbProviderFactories.GetFactory(FactoryType)
        Connection = Factory.CreateConnection
        Connection.ConnectionString = ConnectString
        Connection.Open()
        ' Request a list of tables from the database
        ' ** Tried both with restrictions and without
        ' ERROR on this line:
        ' “Arithmetic operation resulted in an overflow.”
        TablesData = Connection.GetSchema("Tables")
        ' Show the list of tables on the screen in a grid
        ' If it was successful.
        OnScreenGrid.AutoGenerateColumns = True
        OnScreenGrid.DataSource = TablesData
    Catch ex As Exception
        ' Report the error
        err = ex.Message
        If Not (ex.InnerException Is Nothing) Then
            If Not (ex.InnerException.Message Is Nothing) Then
                err = err + nl + nl + ex.InnerException.Message
            End If
        End If
        MsgBox(err, MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "Error")
    Finally
        ' Clean up and Close the DB Connection
        If Not (Connection Is Nothing) Then
            Connection.Close()
            Connection.Dispose()
            Connection = Nothing
        End If
    End Try
    Any Thoughts?  Is this a known bug?  Is there a fix?

    I doubt on line
    OnScreenGrid.DataSource = TablesData
    instead of array as TablesData try to take List object and assign it to OnScreenGrid.DataSource
    just in case check this
    DataGridView.AutoGenerateColumns Property (System.Windows.Forms)
    I might be wrong but just check it

  • Overflow for arithmetical operation (type P) in program.

    Hi experts..
    I had developed a report for showing total receipt and issues and confirmed issue.
    of PQ.
    For all the plant is running fine but only for one plant 2050 its going into dump and error is "Overflow for arithmetical operation (type P) in program." and the code line is
    T_EKET-MNG02 = T_EKET-MNG02 * ( t_mdbs-umrez / t_mdbs-umren ).
    MNG02 IS OF TYPE  Data : "Quan", length =13 , decimal = 3.
    initially : value in Mng02 is =  10       and ratio is 11/8 = 1.375
                  and in the debugging the value is   10*1.375 = 13.75
    but... when i am executing it .. its going into dump and after again checking the MNG02 is showing valude --9765133613.881  and the above error.
    what should i do....
    please help..
    i will award the points for every help...
    thanks

    Hi,
    Are you doing any other calculation for field MNG02 in your program?
    I created a small program with the field and values you have mentioned and it gave me the result 13.75 and no short dump.
    Please check following things:
    When short dump occurs, it shows at which line it has occured. Is it showing that the shortdump has occurs on the line you are talking about here or it is somewhere else.
    Also, when shortdump occurs, it shows a "debugging" button at the top. Hit that button and it will show you exactly where the short dump has occured. What ever this statement is, check what are the values of different variables here.
    Check all these and you might get the answer. Let me know if you still have problem.
    Regards,
    RS

  • Overflow during the arithmetical operation (type P) in program "SAPLHRPT

    Hi,
    I am currently facing an issue in payroll posting to accounting in international payroll.A run time error "Overflow during the arithmetical operation (type P) in program "SAPLHRPT" occurs. By reducing the amounts on the balance sheet side payroll posting document is created.

    Hi Asad,
    Does you guys enhancemented this program? I think if it`s standard code, it should give you a error message inform you "amount is too large" or something.
    So double click this dump log, to check whether it is a custom code, if yes, to add "TRY CATCH" and give out a message.
    regards,
    Archer

  • Overflow during the arithmetical operation (type P) in program "SAPLV61A

    hi,
        I am getting this error in VA01(sales order)
    Runtime error              Compute_bcd_overflow
    Except                       Cx_sy_arithmetic_overflow.
    Overflow during the arithmetical operation (type P) in program "SAPLV61A
    Error in particular line is.
    1388           ADD  xkomv-kwert  TO komp-mwsbp.
    Please give me the solution with detail decsription.How to solve with step by step.

    Hi,
    Instead of directly assigning the value to xkomv-kbetr. Store the value in a temporary variable of type p length 13 decimals 2 . Multiply by 10^n to get the correct result.
    Then assign the temp value to xkomv-kbetr.
    Sample Code
    DATA : lv_temp TYPE P length 13 decimals 2.
    lv_temp = ( xkwert * 10^n ) / komp-mgame. 
    Then assign lv_temp to xkomv-kbetr.
    To get proper value, you have to multiply or divide by 10^n .
    Regards,
    DPM

  • Overflow during the arithmetical operation (type P) in program SAPLBBP_FRA

    Hi All
    I am receieving the following error the moment I log onto the SRM system via the browser.
    Overflow during the arithmetical operation (type P) in program SAPLBBP_FRAMEWORK
    Please can you advise what could possibly the problem.
    Thanks in Advance
    Regards
    KC

    Hi
    <b>Please go through this SAP OSS Note which will definitely help -></b>
    Note 857137 - MENUDATA: A "short dump" occurs with several role assignment
    <u>Do let me know.</u>
    Regards
    - Atul

Maybe you are looking for

  • How to output the member UDA as a column in Report Script?

    I tagged my account dimension members according to its classification instead of using an attribute dimension. I wanted to use the assigned UDA for data loading purpose (select/reject records in rule file. Please let me know the syntax to show UDA as

  • K8NGM2-FID MOBO Keeps beeping in Windows

    Hi, I've had this mobo/pc for 2 years, and it all of a sudden the mobo pc speaker started beeping while Windows is loaded. Temperature isn't an issue, I checked several times. I formated the harddrive and tried to install windows again, and it starte

  • Can barely hear the other person when talking on the phone

    when using the phone function i can barely hear the other person on the line.. the speker volume is at the max.

  • JNDI Lookup of EJB fails

    Hello, I have installed JDeveloper 9.0.3 on windows. I created a workspace and sample project for testing. Added a CMP EJB (Dept) using JDevs "create EJB from table option", added a client to test the EJB using JDevs 'New Sample Client" option, compi

  • How do i create a report that has drill-down with class?

    How do I create a report that has drill-down levels so that I can have summary information at the top level but then view specific records at a more detailed level?