How to truncate the floats?

I like to know how to truncate the floats to 2 decimal points because when I got 500.00 - 0.10, I get 499.9000000000...
So how do I say 499.90?

Try using NumberFormat class:
NumberFormat currency = NumberFormat.getNumberInstance();
currency.setMinimumFractionDigits(2);
currency.setMaximumFractionDigits(2);
String s = currency.format(anyFloatValue);
..

Similar Messages

  • How to make the float variable 1,6000000000000000E+2 as 160 ?

    hi, Can you help me how to convert the float type so that it can looks much better to users .
    Regards ,

    Consider the code below, its serves your requirement, make changes accordingly
    data:
    expo type ANZ_TAGE,
    temp(16) type p decimals 14.
    expo = '3.9604320000000000E+08'.
    move expo to temp.
    write: expo,temp.
    Reward points if useful, get back in case of query...
    Cheers!!!

  • How to truncate the values from the table

    Hi All,
    I am working on an issue..where we are first deleting all the records from the table and then based on few conditions we are putting the records back in that table...when we tried to run this program along with few others those who are doing almost the same stuff we are having issues...we tried to schedule few jobs related to these programs only...but after a ceratin amount of time couple of jobs got canceled...I was talking to my basis guy and he said the problem is ratehr then truncating the records from the table we are deleting the records and it's taking lots and lots of space to execute...so we need to truncate the records from the table insted of deleting it...we are using the following the statement right now:
        DELETE FROM ZTUS_PG.
        COMMIT WORK.
    So can you please tell me how can we truncate the values from this table instead of just deleting them and what would be effect of this.
    Thanks,
    Rajeev Gupta

    I don't think basis is saying you should delete all the records from the table. They are saying remove the table and it's contents (a much faster thing to do). I'm not sure this the right thing to do, but you can have a look at:
    http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.sample.doc/doc/admin_scripts/s-truncate-db2.htm
    Something like:
    EXEC SQL.
      TRUNCATE TABLE ZTUS_PG REUSE STORAGE
    ENDEXEC.
    COMMIT WORK.                      "Empty table is committed here
    Rob
    Edited by: Rob Burbank on Dec 1, 2008 4:06 PM

  • How to truncate the Table Subpartition ??

    Hi,
    I have 3 tables on my Oracle 10g database. They are interrelated as 1 --> 2 ---> 3,
    Table 1 & 2 are composite partiitoned with Partition By Rage and Sub Pratition by list. Now i have to truncate few listed subpartitions i.e
    Say If Subpartition ( 200501, 200601, 200701) , In this subpartition , I want to truncate only the values of say 200501 & 200601 ,
    How can i do that ?? I have gone throgh the documentation, i have'nt fot any solution for this.
    Chowdary K

    Let me more clear about the problem .,
    There are 3 table each one with interrelated as 1 --> 2 --> 3 , Now i have to truncate the old partitons. I can easly truncate the partitons of table 3 as it does'nt have any child tables and it's straight partitoned table. The problem is , 1 & 2 tables are composite partitioned with Partition By Range & subpartitioned by list., Now i have to truncate the few elements of subpartition of 1 & 2 tables.,
    Ex.,
    CREATE TABLE CUST_INVC
    MRKT_ID NUMBER NOT NULL,
    CUST_INVC_ID NUMBER NOT NULL,
    INVC_CMPGN_NR NUMBER(6) NOT NULL,
    CREAT_USER_ID VARCHAR2(100 BYTE) NOT NULL,
    CREAT_TS DATE NOT NULL,
    LAST_UPDT_USER_ID VARCHAR2(100 BYTE) NOT NULL,
    LAST_UPDT_TS DATE NOT NULL,
    ACCT_NR NUMBER(15) NOT NULL,
    CUST_ID NUMBER(15),
    ORD_CREATR_CD VARCHAR2(15 BYTE),
    CMPGN_YR_NR NUMBER(4),
    CMPGN_NR NUMBER(2),
    INVC_DT DATE,
    ORD_SBMSN_DT DATE,
    AVON_ORD_ID NUMBER,
    AVON_STOR_CNFRMTN_NR VARCHAR2(100 BYTE),
    MRGD_INVC_ID NUMBER,
    INVC_TYP VARCHAR2(15 BYTE),
    CUST_SERVC_CHRG_AMT NUMBER(15,2),
    TOT_INVC_AMT NUMBER(15,2),
    TOT_ITEM_CNT NUMBER(8),
    CUST_INVC_TAX_PCT NUMBER(8,3),
    CUST_INVC_TAX_AMT NUMBER(15,2),
    INVC_ADJSTMT_PCT NUMBER(8,3),
    EMAIL_ADDR_TXT VARCHAR2(100 BYTE),
    BILNG_ADDR_CARE_OF_NM VARCHAR2(100 BYTE),
    BILNG_STR_ADDR_TXT VARCHAR2(100 BYTE),
    BILNG_CITY_NM VARCHAR2(100 BYTE),
    BILNG_PRVNC_NM VARCHAR2(100 BYTE),
    BILNG_ST_CD VARCHAR2(5 BYTE),
    BILNG_PSTL_CD VARCHAR2(15 BYTE),
    BILNG_CNTRY_CD VARCHAR2(5 BYTE),
    SHPNG_STR_ADDR_TXT VARCHAR2(100 BYTE),
    SHPNG_CITY_NM VARCHAR2(100 BYTE),
    SHPNG_PRVNC_NM VARCHAR2(100 BYTE),
    SHPNG_ST_CD VARCHAR2(5 BYTE),
    SHPNG_PSTL_CD VARCHAR2(15 BYTE),
    SHPNG_CNTRY_CD VARCHAR2(5 BYTE),
    CUST_PRMRY_PHON_NR VARCHAR2(20 BYTE),
    SHPNG_FEE_AMT NUMBER(15,2),
    REFRG_REP_PHON_NR VARCHAR2(20 BYTE),
    PROMTNL_CPN_CD VARCHAR2(50 BYTE),
    APLCTN_SRCE_CD VARCHAR2(15 BYTE),
    INVC_PRSNL_CMNT_TXT VARCHAR2(500 BYTE),
    INVC_MRKTG_CMNT_TXT VARCHAR2(500 BYTE),
    READY_TO_PRNT_CD VARCHAR2(5 BYTE) DEFAULT 'N',
    ORD_CREATN_DT DATE,
    INVC_VWD_IND VARCHAR2(1 BYTE) DEFAULT 'N',
    INVC_PRCS_ID VARCHAR2(15 BYTE)
    TABLESPACE ECOM_ODS
    PCTUSED 0
    PCTFREE 10
    INITRANS 5
    MAXTRANS 255
    LOGGING
    PARTITION BY RANGE (MRKT_ID)
    SUBPARTITION BY LIST (INVC_CMPGN_NR)
    PARTITION CUST_INVC_US VALUES LESS THAN (76)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE ECOM_ODS
    PCTFREE 10
    INITRANS 5
    MAXTRANS 255
    STORAGE (
    INITIAL 20M
    BUFFER_POOL DEFAULT
    ( SUBPARTITION CUST_INVC_US_SP01 VALUES (200501, 200604, 200707) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP02 VALUES (200502, 200605, 200708) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP03 VALUES (200503, 200606, 200709) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP04 VALUES (200504, 200607, 200710) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP05 VALUES (200505, 200608, 200711) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP06 VALUES (200506, 200609, 200712) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP07 VALUES (200507, 200610, 200713) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP08 VALUES (200508, 200611, 200714) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP09 VALUES (200509, 200612, 200715) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP10 VALUES (200510, 200613, 200716) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP11 VALUES (200511, 200614, 200717) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP12 VALUES (200512, 200615, 200718) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP13 VALUES (200513, 200616, 200719) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP14 VALUES (200514, 200617, 200720) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP15 VALUES (200515, 200618, 200721) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP16 VALUES (200516, 200619, 200722) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP17 VALUES (200517, 200620, 200723) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP18 VALUES (200518, 200621, 200724) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP19 VALUES (200519, 200622, 200725) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP20 VALUES (200520, 200623, 200726) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP21 VALUES (200521, 200624, 200727) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP22 VALUES (200522, 200625, 200801) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP23 VALUES (200523, 200626, 200802) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP24 VALUES (200524, 200627, 200803) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP25 VALUES (200525, 200701, 200804) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP26 VALUES (200526, 200702, 200805) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP27 VALUES (200527, 200703, 200806) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP28 VALUES (200601, 200704, 200807) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP29 VALUES (200602, 200705, 200808) TABLESPACE ECOM_ODS,
    SUBPARTITION CUST_INVC_US_SP30 VALUES (200603, 200706, 200809) TABLESPACE ECOM_ODS )
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING
    ENABLE ROW MOVEMENT;
    Say I want to truncate the Subpartiton CUST_INVC_US_SP30 Values 200603 & 200706.
    Can anyone tell me syntax , how can i do that.,
    Chowdary K

  • Photoshop CC 2014: how to dock the floating Options bar?

    hi Photoshoppers,
    Anyone know how to dock the Options bar in PS CC 2014? When I open it for the first time, it floats. I tried looking this up online and can't find a solution. I figure it can't be rocket science.
    kind regards,
    -c

    Ok, let's go for a Preferences Reset.
    Windows - CTRL-SHIFT-ALT immediately after you double-click the PS icon.
    Macintosh - CMD-SHIFT-OPTION immediately after you double-click the PS icon.
    Wait for the "Delete Photoshop Settings" dialog, release the keys and click "Yes"

  • How to truncate the Dimensions: ORA-02266

    I simply want to truncate the dimensions of star schema.
    First I truncate the fact table with Sql, that works.
    Then truncating a dimension fails with this error:
    Truncate table fcDwh.DIM_DEPS
    Error report:
    SQL Error: ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    02266. 00000 - "unique/primary keys in table referenced by enabled foreign keys"
    *Cause:    An attempt was made to truncate a table with unique or
    primary keys referenced by foreign keys enabled in another table.
    Other operations not allowed are dropping/truncating a partition of a
    partitioned table or an ALTER TABLE EXCHANGE PARTITION.
    *Action:   Before performing the above operations the table, disable the
    foreign key constraints in other tables. You can see what
    constraints are referencing a table by issuing the following
    command:
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = "tabnam";
    If the fact table is already empty, I don't violate any foreign key constraint.
    Or am I wrong with this?
    The constraints below:
    OWNER CONSTRAINT_NAME CONSTRAINT_TYPE TABLE_NAME SEARCH_CONDITION R_OWNER R_CONSTRAINT_NAME DELETE_RULE STATUS DEFERRABLE DEFERRED VALIDATED GENERATED BAD RELY LAST_CHANGE INDEX_OWNER INDEX_NAME INVALID VIEW_RELATED
    FCDWH SYS_C0019008 C DIM_DEPS "DIMENSION_KEY" IS NOT NULL ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED GENERATED NAME 07-SEP-07
    FCDWH DIM_DEPS_DIMENSION_KEY_PK P DIM_DEPS ENABLED NOT DEFERRABLE IMMEDIATE VALIDATED USER NAME 07-SEP-07 FCDWH DIM_DEPS_DIMENSION_KEY_PK

    Try using NumberFormat class:
    NumberFormat currency = NumberFormat.getNumberInstance();
    currency.setMinimumFractionDigits(2);
    currency.setMaximumFractionDigits(2);
    String s = currency.format(anyFloatValue);
    ..

  • How to take the floating point adder output

    I have a piece of code in VHDL here : Floating Point(IP Core) Adder.
    I want to take the result_fp to the output signal test. The result_fp is not affecting the test signal.
    Line 142 :  test <= STD_LOGIC_VECTOR(b_fp);
    I have tried with
    test <= STD_LOGIC_VECTOR(result_fp);
    as well as
    test <= result_fp;
    Not working.
    How can I solve this.
    clockIn input is fed with a square wave of 50 ns period.
    clk_fp is fed with a square wave of 10 ns period(faster clock).
    Timing diagram:

  • How to create the floating message view like Map app and Safari does?

    Hi, guys,
    I am trying to implement a information message view like the Map app and the Safari does.
    Here is the description:
    1. When you drop a pin in the Map app and then tap on the pin, you always can see a floating transparent message on the top of the pin.
    2. When you tap and hold on a link in the Safari app for a few seconds, you can also see a same message view like the Map app does and without showing the disclosure button.
    All I want is such kind of thing, but I had look through out the documentation and the Interface Builder components list. I can not find such a component.
    Does anybody has a similar experience on implement this?
    Thank you guys..

    You're not going to find a control to do this for you. You will have to create a subview and set the properties (color, frame, etc) yourself.

  • How to truncate the decimals in the ALV report for the quantity field

    Hi All,
    I have to display a quantity field and units of measure in the ALV output. If the units of measure eq 'PC' i should not display the decimal places for quantity in the alv output, otherwise i have to display the decimals in the output. How to do this....any help would be highly rewarded. I knew that for this type of cases decimal_o will not work.

    Hi,
    Declare one more Internal table same as output table. In that intead of that quantity field, declare field_name(15) type c.
    data temp type i.
    Loop at itab.
    if field = 'PC'.
    temp = qunantity field.
    field_name =temp.
    else.
    field_name = quantity field.
    endif.
    endif.
    endloop.

  • How to truncate the first part of ID

    My problem is this.
    In my Service Request i have create a new field. I want that this field is the last 6 number of the N. SR
    How do i do?
    Sostantially if the N. SR is 485218-305439087 my field must be 439087(the last 6 number of N.SR).
    Thank you
    Regards Vale

    The expression for the new field must be Left([<SRNumber>],6)
    Regards Catalina Valadez

  • How to stop the floating AirPlay icon

    I want to get rid of the Airplay icon that floats over my photos while I play music? I am using my photos as the screen saver and has this icon all the time. What setting do I need to change?

    Hi Winston,
    That worked perfect.
    Are those your dogs? We also have two German Shepherds. Brother and one is 11 and the other is 10 1/2. The big boy was 166 lbs last year and is on a diet. Now 132.
    Thanks for the help,

  • How to truncate the text in a table column

    Hi all,
    I have a text column in a table RN. the column length is varchar2(240). When the text is too long I want to only display 20 text and followed by '...'
    So I change the xmlfile of tableRN maximumLength="240" columns="80"
    but the text is still long and let the page very wide. I notice the standard page have this functionality while I don't find any control either in the xml file or in the CO class.
    Can anyone show me the method to implement this? I really don't want to modify the VO to decode the column to contain '...'
    Thanks & Regards,
    Scott
    Edited by: Typhoon on Aug 5, 2009 1:07 PM
    Edited by: Typhoon on Aug 5, 2009 1:25 PM

    I have resolve it, by adding these code in VOimpl.java
    super.executeQuery();
    oracle.jbo.RowSetIterator rowsetiterator = OIEUtil.getNoValIterator(this);
    Object obj = null;
    TrackExpenseReportsVORowImpl trackexpensereportsvorowimpl;
    for(; rowsetiterator.hasNext(); trackexpensereportsvorowimpl.setPurpose(OIEUtil.trimString(trackexpensereportsvorowimpl.getPurpose())))
    trackexpensereportsvorowimpl = (TrackExpenseReportsVORowImpl)rowsetiterator.next();
    ---------------------------------------------------------------OIEUtil.class-----------------------------------------------------------------------------------------
    public static RowSetIterator getNoValIterator(ViewObject viewobject)
    RowSetIterator rowsetiterator = viewobject.findRowSetIterator("noValidationIterator");
    if(rowsetiterator == null)
    rowsetiterator = viewobject.createRowSetIterator("noValidationIterator");
    rowsetiterator.setRangeSize(-1);
    rowsetiterator.setRowValidation(false);
    rowsetiterator.reset();
    return rowsetiterator;
    public static String trimString(String s)
    if(s == null)
    return s;
    if(s.length() < 20)
    return s;
    else
    return s.substring(0, 20) + "...";
    }

  • How to truncate the value to the nearest Integer

    Hi friends,
    am using
    select months_between(:to_date,:from_date) from dual which returns like
    12.8387096774194
    when I pass these parameters in to_date and from_date
    10/5/2011 15/4/2010
    now I want this value to be rounded off to 13
    and if the difference is like 0.2322
    it should give me 1
    if the difference is like 1.6 it should give me 2
    pls suggest a solution

    Looks like you want CEIL:
    SQL> with t as (
      2   select 12.838 n from dual union all
      3   select 0.2322 n from dual union all
      4   select 1.6 n from dual
      5  )
      6  --
      7  --
      8  select n, ceil(n) n_ceiled from t
      9  /
                  N        N_CEILED
             12.838              13
              .2322               1
                1.6               2

  • How to truncate the first character of a field

    Hi Experts,
             I have a field say X which is having 3 characters say '123'. Now i have to pass only the last 2 values of X to another field Y. that is Y should contain only '23'. Can you please suggest the method to do it.
    Regards,
    Buvana

    Hi,
    You need to use as follows
    var = var+1(2).
    var = var+n(m)
    This means Read two(M) charachter(s) leaving the first one (N)character(s).
    Regards,
    Sesh

  • How to truncate the last 4 characters of a member name?

    <p>Hi,</p><p> </p><p>I've got a few accounts with names ending with the 4 characters:".FCT"</p><p> </p><p>The accounts names are of different length like PL20100.FCT andMK110.FCT</p><p> </p><p>I'm trying to create a rule like PL20100.FCT = PL20100</p><p> </p><p>I've tried to FIX on the accounts without the ".FCT"and to concatenate to get the ".FCT" but it's not allowedto concatenate a member name used on the left hand side.</p><p> </p><p>Any suggestion to do this in a smart way would be greatlyappreciated.</p>

    Try wrapping in a calc block<BR><BR>"PL20100"(<BR>@MEMBER(@CONCATENATE(@NAME("PL20100"), ".FCT")) = "PL20100";<BR>)<BR><BR>You might have to play with this a little, but the idea should work.

Maybe you are looking for

  • Dynamic Action on IT0002 for France-Molga 06

    Hello, I would like to set up a dynamic action on IT0002 for France (Molga 06) - field State - 'GBDEP'. The field 'GBDEP' is a mandatory field for France, but the business is not maintaining the record of the Birth State of an employees. So I would l

  • How do I share the itunes library between computers when home share is turned on

    I have 2 computers authorized and home share is on, but I can't see the music library on both computers

  • Speaker not working good .. help please

    so when i play music on my phone it seems like it only plays from the right speaker on the bottom of the phone.. not both speakers.. is there a way to turn both speakers on?  My friend has the iphone also and it seems to be coming out of both speaker

  • Vendor master-Bank issueLSMW

    Hi, I am uploading data to vendor master. I am using a previously existing program.....requirement was to upload using separate structures.  So I copied the same program and deleted unnecessary views in that......that way it would be appropriate for

  • Why does useful features are limited to few adapters?

    Why does useful features are limited to few adapters? For eg : File receiver CC has a option to stop Empty messages from being processed. This is not available in SOAP receiver. Is it possible to have a standard adapter module in SOAP receiver CC tha