Get number after decimal

Dear all,
i have a question i have a program working with decimal numbers like 2.30 at some point in my code i have to know what is behind the decimal and put this in a int.
So i have to know how to get a int with the value 30 out of the double with the value of 2.30
There are solution of putting it to a string tokenize this and put the result in a int but there must be ways this can be done in a more basic way.
somebody?
regards,
johan Louwers

An fairly easy way to do it:
( value * 100 ) % 100
Gives us the rest, which since we multiplied it with 100 should give you the two decimal value points as a integer.
I will not delve deeper into the reason why or the worries of losing precision. I just give you the simple solution of accomplishing what you want. :)
Regards,
Peter Norell

Similar Messages

  • How to get values after decimal point

    Hi,
    source value is 12345.678 i wana the target side in 12345  in field and 678 in one field.
    the source value its not fixed  before decimal point value pass to one field and after decimal point value pass to other field
    please help to me how to do this one.

    Hi Swathip,
    You dont need to create 2 UDFs. You just need to create 1 simple UDF which takes one string array as input as usual and it has 2 Resultlist outputs. You need to map this 2 outputs from the UDF to the respective 2 target side fields where the values are to be mapped, one containing the portion before the decimal, and one after the decimal.
    I HAVE TESTED THE UDF AND IT WORKS ABSOLUTELY FINE.
    THE CODE FOR THE UDF IS AS FOLLOWS:
    public void sepDec(String[] num,ResultList wholeNum,ResultList afterDec,Container c)
      String part1=null;  // Stores the part before the decimal point
      String part2=null;  //Stores the part after the decimal point
                            if(num[0]!=null && num[0]!=""){
                   int index = num[0].indexOf(".");
                   part1 = num[0].substring(0,index);
                   part2=num[0].substring(index+1, num[0].length());
                         wholeNum.addValue(part1);
                   afterDec.addValue(part2);
    THIS UDF IS A CLASSIC EXAMPLE WHERE AN UDF HAS 2 OUTPUTS, WHICH IS VERY RARELY SEEN BUT VERY MUCH CORRECT
    PLEASE LET ME KNOW IF THIS CODE WAS HELPFUL TO YOU
    CHEERS,
    BISWAJIT
    Edited by: 007biswa on Feb 8, 2011 5:02 PM

  • Format number after decimal

    this column is defined like this
    studuent_gpa  number(23,9)
    I have a student
    with this gpa
    select studuent_gpa
    from gpa
    where student_id = 117254
    3.816666667
    I just want to dispay
    3.816
    I do
    select studuent_gpa,'99D999')
    from gpa
    where student_id = 117254
    and it rounded, I don't need to rounded just display the three numnbers after the decimal point
    I try diffrent formats and it always rounded
    I need to display 3.816
    Thank you 

    You mean you want something like this?
    SQL> select to_char(floor(3.8166666667*1000)/1000,'99D999') from dual;
    TO_CHAR
      3.816

  • ALV_GRID How to get number of lines after filted applyed?

    Hi, all!
    The task is to display title in alv_grid like
    "N records selected (X records on the screen)".
    It means, N records in dataset and X records displayed after  filter applyed by user.
    But i can't get number of lines after filter applyed from the alv_grid.
    Can anybody help me?
    Thanks & regards,
    Konstantin

    Hi,
    If it goes through PBO/PAI cycle after user sets the filter then in your PBO call method get_filtered_entries of CL_GUI_ALV_GRID and then do a describe statement on the table.
    Number of entries in your grid table - number of entries in this filtered entries table will give you the displayed entries after the filter is set.
    If it does not go through PBO/PAI cycle then register for after_user_command and I think the fcode for filter is '&FILTER' and code for the above logic in your handler method..
    Hope this helps..
    Sri

  • How to get the number of decimal places configured for a site column

    Hi,
    I have a column 'SampleNumCol' of type Number, the number of decimal places to be displayed is configured as 2.
    The column conatins a value, but when retrieved programatically is displayed as 5.00000000  instead of 5.00.
    I am retrieving this column using listitem.Properties[field.InternalName].
    I need to trim the decimals based on  number of decimal places configured for the site column.
    How to get the number of decimal places configured for a site column?
    Thanks in advance,
    dhijit

    Get the field as SPFieldNumber and then check DisplayFormat which returns
    SPNumberFormatTypes
    SPFieldNumber numberField = list.Fields.GetFieldByInternalName("YourNumberFieldName") as SPFieldNumber;
    SPNumberFormatTypes numFormatType = numberField.DisplayFormat;

  • Change number of decimal in general settings after working .

    Hi,
    My customer was upgarded to sap2007 and changed the number of decimal in the "Amount" field to 4 ( it used to be 2)
    now after working a while he needs to change it back.
    Do you know what are the consequences of updating this field using an update query?
    thanks.

    Disaster - first SAP does not permit direct updates to the database it is a violation of agreement with both customers and partners.
    Second - even if you were to update the field your reports, fiancials, etc would never match due to rounding and display differences.
    I am guessing that the client does not like the 4 decimals on the forms and if this is the case they could be changed to display a rounded field by creating a new field, linking to the old field and using a formulae such as round(field_123,2). You would then die the old field.
    It is for this reason that SAP clearly warns you that setup of decimals are critical and cannot be changed after transactions are entered.

  • I purchased Adobe Acrobat XI Standard. How do I get my serial number after sending in the redemption

    I purchased do i get my serial number after posting my redemption code?

    Hi Kerk,
    Please refer the KB Docs : http://helpx.adobe.com/x-productkb/global/redemption-code-help.html
    http://helpx.adobe.com/x-productkb/global/find-serial-number-student-teacher.html
    Regards,
    Ravi

  • Zeroes after decimal getting trimmed after 1:1 mapping of EDIFACT

    hi all
    i have created 1:1 mapping for XML->EDI.
    i took the output from XI and gave it as input.However, in the output of the mapping, the zeroes after decimal are getting deleted.
    for example if the input contain 2500.000, the output of the mapping contains 2500.
    I want 2500.000 in the output.
    Any suggestions as how to overcome the problem?

    hi Kai
    sorry ..i think i didnt convey properly my prob.
    This is what i want.
    My scenario is IDOC->EDIFACT using XI.
    i did a XI graphical mapping from IDOC ->to->EDIFACT_XML.Here for a particular field i got the output as 2500.000.
    Now this EDIFACT_XML is converted into EDIFACt using 1:1 mapping of BIC MD.
    When i give 2500.00 as an input to this 1:1 Mapping of BIC MD, the output contains only 2500.
    I'm not having problem in XI but in BIC MD.
    kindly suggest how i can get decimal output from BIC MD.

  • Make one number after the decimal point

    hi all
    i have a column named quantity from the table job_done
    with values
    1900.8988
    34.67
    0.6788
    236.67
    789999.67676868
    i require the values to be 1900.8
    34.6
    0.6
    236.6
    789999.6
    i just require one number after the decimal point,i know substr but i am confused as to how to achieve this output
    kindly guide
    thanking in advance

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions221.htm#SQLRF06150
    Regards
    Etbin
    Edited by: Etbin on 5.5.2013 14:33
    <tt>substr(quantity,1,instr(quantity,'.') + 1)</tt> if those are not numbers but all contain a decimal point
    Edited by: Etbin on 5.5.2013 14:40
    <tt>case instr(quantity,'.') when 0 then quantity else substr(quantity,1,instr(quantity,'.') + 1) end</tt> when there are no <tt>null</tt> values
    <tt>trunc(to_number(quantity),1)</tt> seems to be the safest if quantities are really <tt>to_char(some_number)</tt>

  • How to get only two digits after decimal point of an expression

    i am doing simple multiplication between two float numbers.
    both the numbers have two digits after decimal point.
    so naturally the result will have 4 digits after decimal point.
    i want to get only two digits after decimal point.
    help me please...

    If you just want to limit the displayed decimal places, you can do the following...
    import java.text.*;
    public class Formatting {
        public static void main(String[] args) {
            NumberFormat format = NumberFormat.getNumberInstance();
            format.setMaximumFractionDigits(2); //what you seem to want
            format.setMinimumFractionDigits(2); //if you always want at least 2 digits displayed
            System.out.println(format.format(12.345));
            System.out.println(format.format(12.0));

  • I have not been sent a serial number after subscribing to Captivate for a year.  Does anyone know how I can get it?

    I have not been sent a serial number after subscribing to Captivate for a year.  Does anyone know how I can get it?  Or how to actually speak to someone in Adobe ??? Very frustrating!
    Thanks

    You have to just sign in with your Adobe Id during the installation process and it will validate your subscription from the activation server. Once your Id is validated then your subscription will be activated. You don't need serial number to activate subscription.
    You may download the product from the link mentioned below.
    https://www.adobe.com/cfusion/tdrc/index.cfm?product=captivate
    Regards,
    Rajeev.

  • Get plan number after calling IP01 using BDC

    Hi,
    I am using IP01 by BDC to create maintenance plan.
    Is there any mthode to get  plan number after the call instead of  reading the message table  within call statment.?
    Thanks.

    One possible way is find an implicit enhancement point and fill up the plan number to memory id and in your bdc call program import the same from memory id

  • BEx Analyzer displays wrong number of decimal places after implementing BW patch

    Hey folks,
    we patched our BW 7.31 from PL10 to PL15 last weekend and now we got some issue with the number of decimal places shown in BEx Analyzer 7.x.
    One example for KF X
    Settings Info Object X
    Decimal Places:                         Not defined
    RSRT - Display X
    Shows 3 decimal places
    Query Designer Settings using KF X
    Number of Descimal Places:     0  [Use Default Settings: NO]
    BEx Analyzer Properties for KF X
    Decimal Places:                         0
    Resulting in BEx Analyzer workbook shows 3 decimal places instead of 0!
    Anyone with an good idea about that?
    Thanks,
    Andreas

    Hi Andreas,
    Have you used the list calulation like "Calculate Result As Average" or "Calculate Single Values as normalization of result" in the relevant key figures?
    For "Calculate Single Values as normalization of result",iIt is the known design that it is always displayed with three decimal places for normalized values, and the setting in Query Designer for
    decimal place doesn't take effect.
    For "Calculate Result As Average", the following note maybe relevant.
    2096911 - Decimal places in query result is wrong, if average is used and display precision is set to less than 3, it will always show 3 decimal places.
    Another clue is to check if the key figure is a Quantity type with unit, and what's defined in table
    T006 field ANDEC for this unit.
    Hope this helpful.
    Regards,
    Ceciclia

  • How to get String after Certain Number of particular characters

    I want to get character after certain numbers's of particular character.
    For example following is String
    String testString = "||A|||B||D|R|T|||TEST|||||"
    I want to get "TEST" which is after 12 "|"
    How can I manupulate String to give me characters after 12 "|"
    I will appreciate any help.

    Loop over the string, looking at each char with charAt(itn index).
    Compare each char to '|'.
    If it matches, increment the counter.
    If the counter is 12, then take the substring from your current position in the string to the end.

  • How can i retain the trailing zeroes after decimal

    how can i retain the trailling zeros after decimal?
    values are showing in table like( 4.50,5.00) but i am trying to do some processing with these values then ithe zeroes are truncated like (4.5,5),
    how can i get values with zeroes

    If the values in the table have trailing zeroes, it's a character type column.
    Once you perform operations on them, they're implicitely converted to the number type, hence "losing" trailing zeroes.
    To get the trailing zeroes back, you have to convert them back to character data:
    TO_CHAR(1.5*3, '90d99')Have fun,
    K.

Maybe you are looking for

  • LV software written in V5.0, need to open in V9.0

    I want to open a program with our newly purchased Labview 9.0.   I received an error stating that the VI's were created in too old of a version of Labview (5.0.1) and cannot be converted to version 9.0. Is there any way around this?   Do I need 1 or

  • Mac OS X Lion won't save my security and privacy settings.

    I unlocked the padlock, then the very top setting option ("Require password *drop box* after sleep or screen saver begins.") I wanted to choose "15 minutes".  However, when I did so, and then clicked the lock again so the padlock was locked, closed S

  • PS CS4 Macintosh

    Just loaded CS4 Standard. All of the brushes in the flyout menu are greyed out. Similarly the Filter>Brush Strokes option is also greyed out. What am I missing?

  • No sound in Flash after resuming from suspend

    After I resume from a suspend or sleep there is no sound in Flash and there is no networking. The only way is to restart my browser to reestablish the sound. Is there a solution for this problem? Thanks.

  • None of my SD cards open on my mac using the SD slot. How do I fix this?

    I have three different SD cards. One I formatted to FAT32 which I think is the correct one for Macs but it still doesn't appear anywhere on my laptop. None of them do. What do I do so I can open them all?