Want to truncate the integer part of a number

hi gurus
My requirement is round off a decimal value
in such a fashion that
if is 12.7767898 then convert to 12.50
again if it is 12.498989 convert to 12.50.
please help
Thanks in advance

You could do something like this:
DATA: number(16) TYPE P DECIMALS 4.
           whole_part(16) TYPE C,
           remainder(4) TYPE C,
           value(20) TYPE C.
MOVE number TO value.
SPLIT value AT ',' INTO whole_part remainder.
Then, examine the remainder:
IF remainder(1) GE '5'.
  remainder = '5000'.
ELSE.
* do something else
ENDIF.
CONCATENATE whole_part ',' remainder INTO value.
In your data display method, display this character string (value) instead of the numerical value (number).
This is a bit unfortunate because you have to type cast your value to string, but it works well enough. Just make sure you don't have any arithmetical operations on this newly created data field because you will get an exception.
Also, please note that this is not the complete solution, but only to give you an idea.
Regards,
SD

Similar Messages

  • Fix the integer part in a decimal numer

    i copy the following code from this forum
    import java.awt.*;
    import java.text.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class Decimal1
      public static void main(String[] args)
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(200,130);
        f.setLocation(400,300);
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        f.getContentPane().add(panel);
        DecimalFormat df = new DecimalFormat("0.00");   
        NumberFormatter nfr= new NumberFormatter(df);
        nfr.setAllowsInvalid(false);
        JFormattedTextField ftf = new JFormattedTextField(nfr);
        JLabel lFtf = new JLabel("JFormattedTextField");
        JLabel lTf = new JLabel("JTextField");
        JTextField tf = new JTextField(8);
        panel.add(lFtf);
        panel.add(ftf);
        panel.add(lTf);
        panel.add(tf);
        f.setVisible(true);
    }i want the user to input the price (the format "99999.99", the integer part is less than 5 digits. the decimal part is fixed to 2 digits)
    for example 56.45, 0.67 12345.99 , 88888.12 are accepted.
    if the integer part is more than 5 is not allowed.
    for example 123456.45, 651433.44
    i try it with Document, buy it cannot work together.
    how can i to solve it?
    thank you!

    You might want to start looking at [url http://forum.java.sun.com/thread.jspa?threadID=5164412&messageID=9629730#9629730]the threads you've previously started on the topic.

  • Getting the integer part of a float?

    This sure is a simple problem, but i couldn't find an appropriate methode or class so i just like to aks you, wheter you have an idea:^
    how do i get the integer part of a float? i mean, how do i get the "14" from the float "14.45698"?

    Sounds like you need to explicitly cast it to an integer, like this:
    double      number1 = 14.45698;
              int     number2 = 0;
              number2 = (int) number1;
    Hope this helps.

  • Adding one day to a oracle.jbo.domain.Date and truncating the time part

    JDev 11.1.1.4.0
    Hello
    I need to add a day to oracle.jbo.domain.Date and get back a oracle.jbo.domain.Date without the time part.
    So far I've got
    Date valueDate = (Date)rowCpt.getAttribute("ValueDate");                                       
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
    cal.add(Calendar.DATE, 1);
    Date newDate = new oracle.jbo.domain.Date(new Timestamp(cal.getTime().getTime()));This adds 1 day to the date but keeps the time part of the date.
    How do I get rid of the time part of the date ?
    Thanks
    Paul

    The Calendar class allows you to set or clear each field.
    Date valueDate = (Date)rowCpt.getAttribute("ValueDate");                                       
    Calendar cal = Calendar.getInstance();
    cal.setTime(new java.util.Date(valueDate.timestampValue().getTime()));
    cal.add(Calendar.DATE, 1);
    cal.clear(Calendar.HOUR);
    cal.clear(Calendar.MINUTE);
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MILLISECOND);
    Date newDate = new oracle.jbo.domain.Date(cal.getTimeInMillis());should work.
    Timo

  • Take the decimal part of a number in mapping

    Hi,
    If I receive a value as 123,456 and I need to map the integer number to FIELD1 and the decimal number to FIELD2 as this:
    FIELD1=123
    FIELD2=456
    Can I do this without using UDFs?

    Hi,
            I don't think this is possible with standard text functions, as inputs to substring function are constants. You definitely need an UDF here.
    String splitNumber(String s,int part,Container container)
              String a[]=new String[2];
              a[0]=a[1]="";
              char decimalSeparetor=',';
              try
                   int i=0,j=0,l;
                   for(l=s.length();i<l && s.charAt(i)!=decimalSeparetor;++i)
                        a[j]=a[j]+s.charAt(i);
                   for(j=1,i=i+1;i<l;++i)
                        a[j]=a[j]+s.charAt(i);
              catch(Exception e)
                   e.printStackTrace();
              return a[part];
    The UDF has two inputs as shown below
    113,567 -------->splitNumber("113,567",0)    ---------->   113 (output)----->FIELD1
    113,567--------->splitNumber("113,567",1)   ------------> 567 (output)------>FIELD2
    113567---------->splitNumber("113567",0)----------------->113567 (output)-------->FIELD1
    113567---------->splitNumber("113567",1)-----------------> no output ------>FIELD2
    The value of integer part (to be supplied as constants) decides which whether you need the part of number before(0) the decimal separetor or after (1).
    regards
    Anupam

  • Can I use the Time Capsule as a backup drive and wired network switch? I do not want to use the wireless part as I already have an ADSL 2  Wireless Router for that. Thanks.

    Hi
    I just went from PC to MAC. Have a MAC Mini and wanted to get a time capsule for backups. I would like to use it as a wired device instead of wireless. Would me connecting it to my router do the trick? Can I then use the LAN ports in the back of the capsule like I would a network switch? Can I just disable the wireless router part of the capsule as I already have an ADSL2+ Wireless Router.
    Thanks

    I wanted to run a cable upstairs from the switch downstairs so the Time capsule becomes my upstairs switch (as I only have Wireless upstairs at the moment. That will work right?
    Cheers.
    Yes, that is also fine.. ethernet being the cable you run.. !!
    You still don't have to use a TC.. which is still a rather expensive box for the job.. an Airport Extreme would offer the same exactly minus hard disk for cheaper price and more than likely better lifespan.. TC with internal power supply run too hot.

  • Returns the integer part of a real number

    Hello,
    I need to know an integer value as part of a real number, like this:
    double a = 0;
    double x = 0;
    x = 1500.00;
    a = (x / 1000);
    now "a" must be equal to 1.
    Pascal has a function INT (a = INT(x/1000)), and what about java ?
    Thanks for help,
    guido

    Hello,
    I need to know an integer value as part of a real
    number, like this:
    double a = 0;
    double x = 0;
    x = 1500.00;
    a = (x / 1000);
    now "a" must be equal to 1.
    Pascal has a function INT (a = INT(x/1000)), and what
    about java ? It is almost the same thing.
    double d = 1.5;
    int i = (int) d;

  • I want to stop the extra part of an E-Mail Address from appearing at beginning during manual type entry

    A couple of upgrades ago I noticed when I started typing an E-Mail Address manually, just as before, it starts coming up with suggestions. NOW, when I select, it adds the search typing in front of the Name and E-Mail Address. Before the Name and E-Mail Address replaced the search typing. Is still does the replace IF there is MORE than one possible displayed and I click on the desired.
    If I type tru I get what I want BUT it enters "tru >> Fire Company Trustees <[email protected]>" into the address line. I put the quotes to show what is actually included, which is the letters tru AND the >>. I now have to remember to go back and "clean up", getting rid of the "tru >>" so it says Fire Company Trustees <[email protected]>
    Very annoying!

    Are you using 34.4? if not please update and see if you still have the issue. As I understand it 34.4 Fixes this.

  • 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

  • Help... how to separate the integer number..?

    please help...
    I want to separate the integer number into 3 parts.
    for example 12085441 the parts become:
    part 1 : 12
    part 2 : 08
    part 3 : 5441
    How to do it...? please Help..
    Thanks....

    I am a student, I am developing a simple program
    which required the date.
    That 8 digits number will be stored in the Ms.Access
    database, and I will store it as text. When the date
    is loaded, I convert to int, then separate it become
    3 parts,
    part 1 for day, part 2 for month and part 3 for
    year.
    The purpose of separating these number is to compare
    or calculate or date sorting purpose on my program. I
    create the Date ADT to receive the number (day,
    month, year), so I can calculate that date.
    Sorry, its quite confusing... I just make simple
    program that implement ADT and Database...If you're talking about dates, then they aren't integers. What date does the "integer" 1112001 represent? 1/11/2001 or 11/1/2001? Are you going to mandate that months January-October be stored with a leading '0'? How are you going to enforce that? How are you going to be sure it's been done? No need to represent a date as an integer, that's just asking for bugs

  • Get integer part of a double type value.

    double dblVal=150.50;
    how will i get the integer part only of variable dblVal?
    i want to get the 150 only. please help.
    killuasoft

    Why would you want to do this? This can overflow your
    int for sufficiently large double values, even when
    using a long instead of an int.Maybe he previously did a range check or otherwise knows the range of possible values.

  • How to wait until the 1st part of the processing is done

    Hi,
    I had a hard time to combine two parts of processing in one .vi file, and thus would like to get some advice/help through the forum.
    Attached is the partial finished vi file I made. You can see that it is composed of two parts. The upper part is to run a bat file (check_result.bat), which generates a result.txt file. The lower part is to use the result.txt file as an input file, and check if the key word called "test case passed" is included in the result.txt file or not. So I want to run the upper part firstly, and then run the lower part after the upper part is finished.
    However, I don't know how to connect the two parts in a right way that the lower part only starts running after the upper part is finished. Any comments/help is highly appreciated.
    Thank you in advance.
    Xuedong 
    Attachments:
    question.vi ‏49 KB

    The magic of dataflow!
    All you need is a data dependency between the two parts. Often critical parts of each section contain error terminals, so you can just string em along in the proper order and each part must wait until the previous node has finished.
    In your particular case, the read operation has no error input, so you can recruit any other input. Create a fake data dependency by strategically placing a small sequence frame containing common code. The sequence cannot start until all code that provides imputs has finished, serving your purpose.
    Of course it seems silly to even try to read the file if the previous node failed. Right? So simply place the second part inside a case and hook it up to the error output. Now the second part (1) waits until the first part has finished AND (2) execute only of the first part succeeded. No sequence needed.
    All clear?  
    Message Edited by altenbach on 02-07-2007 02:34 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    dataflow.gif ‏4 KB
    dataflow2.gif ‏4 KB

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

  • Number field not displaying the decimal part

    Hi,
    In a VO I've an attribute which is of type Number.
    I've set the precision & scale for the attribute as 16,4
    Even though the value in the database is having decimal part still in the UI it is just displaying the integer part.

    I've not generated the VO RowImpl file.
    The problem got solved by setting the format type in the control hints of that particular attribute of the VO.

  • How to skip the regristration part on new macbook? Go straight to login

    I have a 2007 macbook osx n I want to skip the beginning part of the setup n go to login . Is there anything I can type when I press in to command s to skip the regristration?

    Turn off your computer, then turn back on and press F12 (fn + volume button) or hold the mouse or trackpad button before the spining circle or apple logo appear on the gray startup screen

Maybe you are looking for

  • Windows 7 HDMI stops working after login in normal boot. Safe modes work

    Hi guys, I have a problem and I am a complete dummie at this. (Sorry in advance for bad english and hardware/software knowlegde.) Here's what happened: Yesterday evning I turned off my PC after playing my games. Today when I got home from work my PC

  • Backend tables information in Agile PLM 8.5 and 9.3 versions

    I am upgrading Agile PLM version 8.5 that currently has Oracle database 9g, to version 9.3 application and backend Oracle database to 11g. I need to verify the data between Agile database and our EBS database and am wondering if anyone can give me in

  • To print an Pie Chart image with more than 1 slice is not working

    Hi friends, I'm using a version 12.0.4 and when I try to generate an Pie Chart image with more than 1 slice using the function saveImage() it's not working. The image is only generate when its return is just 1 value (1 peace of pie). Anybody help me?

  • Upgrade to CQ 5.6.1 on a self-managed instance

    We have a 5.6.0 instance that we started ourselves in the adobeaemcloud. Now we need to upgrade it to 5.6.1. How can we do the upgrade ourselves? Does it have to be done in the AWS servers or is there a way to do the upgrade from the UI?  Thanks!

  • Wrong capture presets & how to correct them

    Ok, I've been a real dufus: I have shot my material 25fps progressive, 16:9, PAL, DVCam. For reasons I can't comprehend I used the "DV PAL 48 KHz" preset and "Capture Now" to capture my whole tape, which was was successfully imported as 8 seperate cl