Numeric type conversion

Hi, it may be asked by someone before.
But,
public static void main(String[] args){
int i , j = 100;
double temp = i * 0.1;
i = (int) temp; //works
j = (int) j * 0.1; //fails, why?
System.out.println(i);
System.out.println(j);
error: loss of pecision
Any helps appreciate! ^^

Check out this page. When an int and a double are the operands of an arithmetical operation, the result is a double.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arithmetic.html
Hmmm, note that "j = (int) j * 0.1; " is equal to "j = ((int) j) * 0.1;" It should work if you change the statement to "j = (int)( j * 0.1); "

Similar Messages

  • QoQ unsupported numeric type??

    Hi,
    Has anyone successfully used CF_Select from Masrizal? I
    bought the code only
    to find that it's not working with dynamic options.
    Would appreciate suggestions on how to get this to work. TIA
    THis error is coming from this code in the Tag.
    <cfquery dbtype="query" name="qryTemp">
    select * from qryTemp
    order by parent
    </cfquery>
    Error Executing Database Query.
    Query Of Queries runtime error.
    Query Of Queries runtime error.
    Unsupported Numeric type conversion in Query of Queries.
    My Code:
    <cfquery name="getPA" datasource="bibs2">
    select PraticeArea, PraticeAreaID from bibs_tblPraticeArea
    where DeleteFlag = 0 order by PraticeArea
    </cfquery>
    <cfquery name="getBibs" datasource="bibs2">
    Select *
    from bibs_tblBibliographies
    where DeleteFlag = 0
    Order by DateModified Desc
    </cfquery>
    <table border="0">
    <form name="test" action="example.cfm" method="post">
    <tr><td>Pratice Area</td>
    <td>
    <cf_select name="PraticeArea" formname="test"
    passthrough="style='background-color:##000000;
    color:##ffffff;'">
    <cf_option value="">Select Pratice
    Area</cf_option>
    <cfoutput query="getpa">
    <cf_option
    value="#PraticeAreaID#">#PraticeArea#</cf_option>
    </cfoutput>
    </cf_select>
    </td>
    </tr>
    <tr><td>Bibs</td>
    <td>
    <cf_select name="BiBs" parent="PraticeArea"
    formname="test"
    passthrough="style='background-color:##000000;
    color:##ffffff;'">
    <cf_option value="" parent="">Select
    Bib</cf_option>
    <cfoutput query="getBibs">
    <cf_option value="#BIBSID#"
    parent="#PraticeArea#">#Title#</cf_option>
    </cfoutput>
    </cf_select>
    </td>
    </tr>
    <tr>
    <td>
    <br>
    <input name="Submit" type="Submit">
    </td>
    </tr>
    </form>
    <!--- view posted form --->
    <cfif isdefined("form.Submit")>
    <tr>
    <td >
    <hr>
    <cfoutput>
    You have selected this:<br>
    <cfloop collection="#form#" item="key">
    <cfif key neq "fieldnames" and key neq "submit">
    #Key#: #evaluate("form.#key#")#<br>
    </cfif>
    </cfloop>
    </cfoutput>
    </td>
    </tr>
    </cfif>
    </table>

    Solution: #jsstringformat()#
    Example:
    <cf_select name="PraticeArea" formname="test"
    passthrough="style='background-color:##000000;
    color:##ffffff;'">
    <cf_option value="">Select Pratice
    Area</cf_option>
    <cfoutput query="getpa">
    <cf_option
    value="#jsstringformati(PraticeAreaID)#">#PraticeArea#</cf_option>
    </cfoutput>
    </cf_select>
    <cf_select name="BiBs" parent="PraticeArea"
    formname="test"
    passthrough="style='background-color:##000000;
    color:##ffffff;'">
    <cf_option value="" parent="">Select
    Bib</cf_option>
    <cfoutput query="getBibs">
    <cf_option value="#jsstringformat(BIBSID)#"
    parent="#jsstringformat(PraticeArea)#">#Title#</cf_option>
    </cfoutput>
    </cf_select>
    thanks for all the respond!
    "is" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Has anyone successfully used CF_Select from Masrizal? I
    bought the code
    only
    > to find that it's not working with dynamic options.
    > Would appreciate suggestions on how to get this to work.
    TIA
    >
    > THis error is coming from this code in the Tag.
    >
    > <cfquery dbtype="query" name="qryTemp">
    > select * from qryTemp
    > order by parent
    > </cfquery>
    > Error Executing Database Query.
    >
    > Query Of Queries runtime error.
    > Query Of Queries runtime error.
    > Unsupported Numeric type conversion in Query of Queries.
    >
    >
    >
    >
    >
    >
    >
    > My Code:
    > <cfquery name="getPA" datasource="bibs2">
    > select PraticeArea, PraticeAreaID from
    bibs_tblPraticeArea
    > where DeleteFlag = 0 order by PraticeArea
    > </cfquery>
    >
    > <cfquery name="getBibs" datasource="bibs2">
    > Select *
    > from bibs_tblBibliographies
    > where DeleteFlag = 0
    > Order by DateModified Desc
    > </cfquery>
    >
    >
    > <table border="0">
    > <form name="test" action="example.cfm"
    method="post">
    > <tr><td>Pratice Area</td>
    > <td>
    > <cf_select name="PraticeArea" formname="test"
    > passthrough="style='background-color:##000000;
    color:##ffffff;'">
    > <cf_option value="">Select Pratice
    Area</cf_option>
    > <cfoutput query="getpa">
    > <cf_option
    value="#PraticeAreaID#">#PraticeArea#</cf_option>
    > </cfoutput>
    > </cf_select>
    > </td>
    > </tr>
    >
    > <tr><td>Bibs</td>
    > <td>
    > <cf_select name="BiBs" parent="PraticeArea"
    formname="test"
    > passthrough="style='background-color:##000000;
    color:##ffffff;'">
    > <cf_option value="" parent="">Select
    Bib</cf_option>
    > <cfoutput query="getBibs">
    > <cf_option value="#BIBSID#"
    > parent="#PraticeArea#">#Title#</cf_option>
    > </cfoutput>
    > </cf_select>
    > </td>
    > </tr>
    >
    > <tr>
    > <td>
    > <br>
    > <input name="Submit" type="Submit">
    > </td>
    > </tr>
    > </form>
    >
    > <!--- view posted form --->
    > <cfif isdefined("form.Submit")>
    > <tr>
    > <td >
    > <hr>
    > <cfoutput>
    > You have selected this:<br>
    > <cfloop collection="#form#" item="key">
    > <cfif key neq "fieldnames" and key neq "submit">
    > #Key#: #evaluate("form.#key#")#<br>
    > </cfif>
    > </cfloop>
    > </cfoutput>
    > </td>
    > </tr>
    > </cfif>
    > </table>
    >
    >
    >
    >
    >
    >

  • Data type conversion from packed to numeric

    Hi Experts,
    i have a question on data type conversion. My requirement is:
    i have fields of type packed decimal in my internal table itab. I need to convert the values of packed decimal fields in itab to numeric type.
    Example:
    Data: begin of itab occurs 0,
                ebeln like ekko-ebeln,
                ebelp like ekpo-ebelp,
                menge(15) type p decimals 2,
                netpr(15) type p decimals 2,
              end of itab. 
    if itab-menge has a value of 2.00, i need to convert that value to '         200'.  Right justified.
    if itab-netpr has a value of 1,234.56, i need to convert that to '         123456'.
    The above internal table itab is passed to the Function module GUI_DOWNLOAD and the itab data is downloaded to a text file.
    Please let me know how to acheive this objective.

    Hi ,
    You can use
    SPLIT at '.' into v1 v2
    concatenate v1 v2 into vv1.
    REPORT ZDN_TEST_001 .
    data: lv_var1(15) type p decimals 2 value '123.00'.
    data: lv_var2(15) type p decimals 5 value '123.12121'.
    data: lv_varc1(15) type c.
    data: lv_varc2(15) type c.
    data: lv_varc1d(2) type c.
    data: lv_varc2d(5) type c.
    data: lv_varc11(15) type c.
    data: lv_varc21(15) type c.
    write:/ lv_var1.
    write:/ lv_var2.
    *1)write & REPLACE.
    write lv_var1 to lv_varc1.
    write lv_var2 to lv_varc2.
    REPLACE '.' WITH SPACE INTO lv_varc1.
                 CONDENSE lv_varc1 NO-GAPS.
    REPLACE '.' WITH SPACE INTO lv_varc2.
                 CONDENSE lv_varc2 NO-GAPS.
    write:/ lv_varc1.
    write:/ lv_varc2.
    *2)split & concatinate
    write lv_var1 to lv_varc1.
    write lv_var2 to lv_varc2.
    split lv_varc1 at '.' into lv_varc1 lv_varc1d.
    concatenate lv_varc1 lv_varc1d into lv_varc11.
    split lv_varc2 at '.' into lv_varc2 lv_varc2d.
    concatenate lv_varc2 lv_varc2d into lv_varc21.
    write:/ lv_varc11.
    write:/ lv_varc21.

  • Implicit and explicit Type conversion using Type object in heap

    Hi,
    I am surprised how Implicit and explicit Type conversion works using Type object in heap. for example when implicit type conversion occur what pointer it returns to object and similarly with explicit type conversion.

    Hello,
    >> I am surprised how Implicit and explicit Type conversion works using Type object in heap.
    For Implicit conversions: Typical examples are conversions from smaller to larger integral types, and conversions from derived classes to base classes. For the first one, the reference would be different which means it would return a different pointer to
    a new object. For the reference type, it actually points to the same memory location, you could use the object.ReferenceEquals() to check it.
    For Explicit conversions (casts):Typical examples include numeric conversion to a type that has less precision or a smaller range, and conversion of a base-class instance to a derived class. For first one, it would perform the same with implicit conversions.
    While for the conversion of conversion of a base-class instance to a derived class, actually, there's no built-in way to do this conversion.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Numeric type source field

    Hello.
    I try to make one of my source field as integer. I use XSD Schema and I've already tried all of xsd numeric data types  (like Integer, int, short , byte) - In all cases in Import manager I get always "Text" type.
    Dmitry

    Hi Dmitry,
    If you have mapped numeric/boolean/ccurency etc to text field in Import manager,there will be an automatic type conversion based on type of the destination field.
    This is what you are seeing in the import manager in "type".
    For further details please go to page 225 of Import manager guide.
    Thanks,
    Ravi

  • Passing regexp_replace backreference to a function; type conversion problem

    I am trying to convert some text within my CLOB field to HTML links.
    The format of the (part of the link I am having problems with) is:
    <link 12>
    which I wish to convert to
    url_dest
    I am trying to pass the backreference \1 (being the number 12 in this case) in regexp_replace to a simple function I have made and when I run it I receive the error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    I have tested the function on its own with passing a string and it works fine.
    I have passed the string from the backreference to the function and back out as the return value and it works fine.
    However, when I try to pass the string back reference (a set of digits) to use as the NUMBER ID in my where clause, it always returns this error. I have tried CASTing / TO_NUMBER in every way possible I can think of, using temporary variables etc. and still the same error.
    =====
    CREATE OR REPLACE
    FUNCTION GETLINK (linkid IN CLOB)
    RETURN VARCHAR2 AS
    linkstring VARCHAR2(4000);
    linkchar VARCHAR(4000);
    linkint NUMBER;
    BEGIN
    linkchar := TO_CHAR(linkid);
    linkint := TO_NUMBER(linkchar);
    SELECT url_dest INTO linkstring FROM TABLE WHERE ID = linkint;
    RETURN linkstring;
    END;
    =====
    Offending calling code:
    tempcontent := regexp_replace(myClobField, '<link ([[:digit:]]*)>', GETLINK('\1'));
    =====
    I have tried implicit and explicit type conversions that vary the above function; in parameters as VARCHAR2; etc.; no joy.
    Is this a bug within the database, is it by design, or is it just me making a hash of things? I really don't want to have to pull the XML into PHP then run the PHP regex functions with Oracle DB queries to do this!
    Many thanks for your assistance.
    Ingram

    Many thanks for the reply, but I'm not sure how that would work. I wish to do a global regexp_replace on all instances of '<link> ([[:digit:]]*)>' within my XML document, with the return value from the GETLINK function.
    So for instance.
    The return value of GETLINK could be in format:
    &lt;a href="\1"&gt;
    so an XML document of:
    =====
    &lt;doc&gt;
    &lt;link 12&gt;Test Link&lt;/link&gt;
    some content
    &lt;link 783&gt;A second Test Link&lt;/link&gt;
    &lt;/doc&gt;
    =====
    would return as:
    =====
    &lt;doc>
    &lt;a href="12"&gt;Test Link&lt;/link&gt;
    some content
    &lt;a href="783"&gt;A second Test Link&lt;/link&gt;
    &lt;/doc&gt;
    =====
    Obviously I would then do the other replacements to fix broken XML with the non matching end tags etc.
    TIA

  • The priority of different data type conversion

    Hi All,
    I want to know the priority of data type conversion rule. if in an expression, I have several kind of data type( I, P, F,N..).
    Then finaly, all the data object will convert to which data type?
    I don't know the priority of data conversion.
    E.g.   data a type i. data b type p. data c type f.
             a = b + c.
    or    data d type p, data e type f.
          if ( d > f ).
    Then who will convert to who's type?
    Thanks and Regards.
    Aaron

    For expressions, the right term in SAP is "calculation type", it's explained here : [abap help - determining the calculation type|http://help.sap.com/abapdocu_70/en/ABENARITH_TYPE.htm]. SAP takes the "biggest" type of all variables in the expression. It can be I, P or F (smallest is I, biggest is F).
    Conditions are handled differently, just using data type conversion (see link given above by Abhishek), SAP converts from smallest to biggest type (in your case, it converts P to F and compares the two F variables).

  • Need Help with data type conversion

    Hello People,
    I am new to java, i need some help with data type conversion:
    I have variable(string) storing IP Address
    IPAddr="10.10.103.10"
    I have to call a library function which passes IP Address and does something and returns me a value.
    The problem I have is that external function call in this library excepts IP Address in form of a byte array.
    Here is the syntax for the function I am calling through my program
    int createDevice (byte[] ipAddress).
    now my problem is I don't know how to convert the string  IPAddr variable into a byte[] ipAddress to pass it through method.

    Class InetAddress has a method
    byte[]      getAddress() You can create an instance using the static method getByName() providing the IP address string as argument.

  • SQL Loader and numeric types

    I'm using SQL Loader to import data from a file, but I'm having trouble with numeric types.
    I'm trying to import an amount into a table. The amount field in the table is of type NUMBER(11,2).
    I suppose that Double is the correct type to use in the ctl-file definition. How do I use this type?
    I've tried to use:
    AMOUNT DOUBLE TERMINATED BY ";" NULLIF BELOP=BLANKS,
    but the I get an error message because I'm using terminated by
    I've also tried using:
    BELOP DOUBLE NULLIF BELOP=BLANKS,
    but then it isn't able to find the delimiter.
    I've tried to search the net for examples using Double, but I haven't found anything of current interest yet.
    So, my question is:
    1. Is Double the correct type to use in this case?
    2. How do I use Double?

    I hardly ever specify a data type in a SQL*Loader control file; I just let Oracle handle it. If it is not the correct datatype for the column Oracle will reject it anyway. The main exception is DATE columns, but even then only because most flat files don't have dates in the default format so the data type specifcation is essentially just a format mask.
    Regards,
    Steve Rooney

  • Problem with numeric types in Abap Proxy

    Hello,
    We are having problems with some abap proxy calls. When a numeric type is filled with 0 the node it´s automatically removed and no value it's recived in XI. The only way I have found to avoid this problem it's to define the field with type string or change the cardinality to 1..1 instead of 0..1. It's there any way to maintain the type and the cardinality?? Maybe with a pattern??
    Regards,
    Alberto Pla.

    Hi Alberto
    I had this problem, and I decided to use xsd:string instead of xsd:integer. This will solve the issue.
    Anyway.. check this note:
    [Note 1242795 - Mapping of XSD default values by ABAP Proxy Generation|https://service.sap.com/sap/support/notes/1242795]
    Regards
    Francesco

  • Invalid data type conversions

    what are the invalid data type conversions in ABAP ???
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 10, 2012 6:01 PM

    No Amanda,
    The values that I see in message monitor are also those that comes to XSLT programs as input.
    I investigated our problem a little further myself:
    1) XI always converts messages into XML format - this everybody knows.
    2) In XI documentation it is declared that XI uses ISO 8601 for DATE type formatting. That's why you see dates in format YYYY-MM-DD in XML data in message monitoring.
    3) The appearance of those decimal values are not that obvious for me. If XI uses ABAP transformation for message content then applies the rules for converting ABAP data types into XML. For this there is a SAP document 'ABAP - XML mapping' from TechEd2004. This document seems to describe how ABAP data types are handled by XML transformation.
    Anyway, we currently need to play with decimal values in XSLT mapping programs inside XI:
    a) add leading 0 integer if source value < 1
    RFC returns 0.123 -> XI converts to XML '.123' -> XSLT mapper should return '0.123' ->SOAP response returns '0.123'
    b) add decimal point and trailing zeros
    RFC returns 0.000 -> XI converts to XML '0' -> XSLT mapper should return '0.000' ->SOAP response return '0.000'
    With dates, the problem is actually on documenting mapping rules when writing interface specifications. If you would write an EAI-solution-independent conversion rule (RFC/date->SOAP/char) for date field it could sound like: YYYYMMDD -> dd.mm.yyyy. This works semantically between these systems but would not work for XI-developer, because he get YYYY-MM-DD from the RFC.
    Additionally the decimal type conversion requirements in XSLT mapping programs probably only applies XI and are therefore not reusable in other EAI environments.
    I would be glad if somebody would still have further comments for this data type conversion issue.
    br: Kimmo

  • WebDynpro call Returns an exception: Type conversion error

    Hi,
    I'm trying to start some of the standard SAP web dynpro .
    most of then work fine.
    some don't and i get the following error message.
    Root Cause
    The initial exception that caused the request to fail, was:
    +com.sap.aii.proxy.framework.core.DataAccessException: Type conversion error, field TAX_PER_DIEMTAX, complex type class com.sap.xss.tra.tre.model.expenses.Ptrv_Web_General_Data_Int+
    +at com.sap.aii.proxy.framework.core.JcoBaseTypeData.propagateJcoException(JcoBaseTypeData.java:130)+
    +at com.sap.aii.proxy.framework.core.JcoBaseTypeData.setElementValue(JcoBaseTypeData.java:751)+
    +at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setAttributeValue(DynamicRFCModelClass.java:482)+
    +at com.sap.tc.webdynpro.progmodel.context.GenericModelClassCopyHelper.setAttributeValue(GenericModelClassCopyHelper.java:69)+
    +at com.sap.tc.webdynpro.progmodel.context.CopyService.copyCorresponding(CopyService.java:55)+
    +... 66 more+
    See full exception chain for details.
    could anyone give me an hint.
    jco connetion are made and testet for:
    sap_r3_humanresources
    sap_r3_finacials
    sap_r3_selfservicegenerics
    sap_r3_travel
    analog the *_MetaData
    Thank in advance
    Maximilian

    Hello
    did you solve this problem? I have the same error
    Regards

  • Data type conversion JCO To ABAP( Double to DEC)

    Hi,
      I want to update a field having data type as DEC with length 11 in APO system using JCO.Whatever i give as input is not getting reflected in APO system. Instead i get some different value.
    It seems that there is some data type conversion for that field..
    Thanks
    Archana

    if(tableName.equals("BAPI10001LOCPRDVERS2"))
                                                           table.appendRow();
                                                           //System.out.println("getting inside table "+tableName);
                                                           table.setValue("SOP112","PRODUCT");
                                                           table.setValue("SCMTEST111","LOCATION");
                                                           table.setValue("1001","LOCTYPE");
                                                           table.setValue("SCMTEST111","LOCATION_INT");
                                                           table.setValue("000","PLANNING_VERSION");
                                                           table.setValue("5000","SAFETY_DAYS_SUPPLY");//this is the field having problem
                                                           table.setValue("5","SAFETY_STOCK");
                                                           table.setValue(" ","SAFTY_STOCK_CALC_METHOD");
                                                           table.setValue("5.00","OPENING_PERIOD");
                                                           table.setValue("15","FORECAST_HORIZON");
                                                           table.setValue(("20000"),"VMI_PROM_LEAD_TIME");
                                                           table.setValue("0","MINIMUM_LOT_SIZE");
                                                           table.setValue(bd1,"TARGET_DAYS_SUPPLY");

  • Formula node: type conversion

    Hello guys
    I have LV 5.0 and have to edit a script which has some kind of overflows. For testing I set all variables to the hightest usable range - extended or i32. Now I see, in all formula nodes, there are type conversions. How can I change the type of the inputs/outputs of the formula node?
    Hardware_Tester
    My first language is German, please ignore my faults...

    Hi,
    I forgot that you run Lv5.0. My example refers to Lv7.1.
    As far as I know in Lv7.1 the input variable type changes automatically as you connect a control.
    On the contrary the output is DBL by default but you can change it in the formula node introducing an explicit declaration of that variable (see "h" in the attached picture).
    Here are some useful link:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=12253&requireLogin=False
    http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/d6bed7d73659c43586256a7300691c26?
     Sorry, I understand that this cannot solve your problem but I don't remember how Lv5.0 works with formula node.
    Regards
    CLD - Labview Certified Developer
    Attachments:
    untitled3.gif ‏42 KB

  • Unicode Type Conversion Error

    Hi Friend,
    I am working in UNICODE project,i need one help,
    I have one error .
    Actually, im using one structure(Z0028) and passing values to internal table.
    At that time i shows one error.
    Actually,this error is due to type conversion problem.
    In that structure,i ve one packed datatype ,so, if i select
    unicode check it shows error.
    I will sent example prg and error also.
    Please give some solution to slove.
    REPORT  YPRG1                                   .
    TABLES: Z0028.
    DATA:I_Z0028 TYPE Z0028 OCCURS 0 WITH HEADER LINE .
    SELECT * FROM Z0028 INTO TABLE I_Z0028 .
    IF SY-SUBRC <> 0 .
      WRITE:/ ' NO DATA'.
    ENDIF.
      LOOP AT I_Z0028.
        WRITE:/ I_Z0028.
      ENDLOOP.
    Regards,
    Kalidas.T

    Hi,
    Display fields
    do like this..
    REPORT YPRG1 .
    TABLES: Z0028.
    DATA:I_Z0028 TYPE Z0028 OCCURS 0 WITH HEADER LINE .
    SELECT * FROM Z0028 INTO TABLE I_Z0028 .
    IF SY-SUBRC 0 .
    WRITE:/ ' NO DATA'.
    ENDIF.
    LOOP AT I_Z0028.
    WRITE:/ I_Z0028-field1,
                  I_Z0028-field2
    I_Z0028-field3.
    ENDLOOP.
    Regards,
    Prashant

Maybe you are looking for