Rounding to the nearest thousand

hi
does anybody know how to ceil and floor an integer to the nearest thousand?
thanks in advance?

hi friend,
try this code, it may help you.....
public class NT {
    /** Creates a new instance of NT */
    public NT() {
    public int roundByThousands(int val)
        int retval=0;
        for(int i=0;i<val;i=i+1000)
            int k=val-i;
            if(k<1000)
                if(k<=500)
                    retval=val-k;
                else
                    retval=(1000-k)+val;
        return retval;
    public static void main(String args[])
        NT nt=new NT();
        System.out.println(nt.roundByThousands(11502));
}

Similar Messages

  • SQL for rounding to the nearest value

    Hi All,
    My Oracle DB version is 10g Release2 and also 11gR1
    I have data like below, I need to write a SQL for the below requirement.
    ID   RANGE_LOW                RANGE_HIGH
    1      50                    55             
    2      55                    60
    3      60                    63 
    4      63                    77 
    5      77                    84   The requirement is like I need to check a value between the above range low and high then round it to the nearest value.
    Say, for example if I have 68 then the value is rounded to 63 else if 74 then 77 else if its in the middle of two values (70) then rounded to the highest value, here its 77.
    Please advice.

    Ashu_Neo wrote:
    hi Purvesh,
    I think , you didn't check it properly with requirement of posting. Your query needs to be changed a bit. Please verify againYes, I probably missed or overlooked the last line.
    Here is the updated solution then:
    with data as
      select 1 id, 50 low, 55 high from dual union all
      select 2, 55, 60 from dual union all
      select 3, 60, 63 from dual union all
      select 4, 63, 77 from dual union all
      select 5, 77, 84 from dual 
    chk_val as
      select &val val from dual
    select id, low, high,
           val input_value,
           case
            when val < (low + high)/2
              then low
            else
              high
           end round_value
      from data, chk_val
    where val between low and high;
    ID                     LOW                    HIGH                   INPUT_VALUE            ROUND_VALUE           
    4                      63                     77                     70                     77

  • How to round numbers to the nearest .25

    I would like to enter a number in one field and have it rounded to the nearest .25 in another column - (whether that's rounding up or down)
    Example:
    Actual Size
    Adjusted Size
    7.21435
    7.25
    Any help would be appreciated.
    Thanks!

    Hi c,
    The ROUND function limits the precision choices to powers of 10, so we need to work within that limitation:
    Multiply by four, round to the nearer whole number, divide by four.
    Formula in column B: =ROUND(A*4,0)/4
    All cells in B are formatted as Number, with decimal places set to 2.
    Regards,
    Barry

  • Rounding to the next 0.5

    I need to round a figure say 3.2 up to the nearest 0.5 so it will become 3.5 but i do not know how to do so as it always round to the nearest integer, from 3.2 to 4.
    Need to know how to do round to 0.5 
    Pls help.
    Ty

    This will roundup anything above 3 but below 3.5 to 3.5.  From 3.5 to 4, it rounds up to 4.0.  However, due to representation errors, sometimes a .5 rounds up to the next integer, sometimes it doesn't.  For example, 10.5 will remain 10.5, but 9.5 will round up to 10.  At least that is how it does on my system.
    - tbob
    Inventor of the WORM Global

  • Rounding off to nearest whole number without condition

    hi,
    i want to round a real number to an integer value,,wihout any conditions like
    10.01 should be 11
    10.1 should be 11 and like that
    is it posible to do it?
    thanks in advance.
    amit

    It doesn't look like you are trying to round to the nearest whole number here. It looks like you are trying to find the smallest integer value that is greater than or equal to the real number. If so, you would want to use the CEIL function (i.e.
      1  SELECT CEIL(10.01)
      2*   FROM dual
    SCOTT @ hp92 Local> /
    CEIL(10.01)
             11Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Rounding minutes to nearest five.

    Hi,
    I have tried the various methods suggested on other forum messages but to no avail.
    I have a GUI that acts as the client for a reminder system i am making for some coursework.
    It contains a combo box with values for the user to select a time from, however the time is not displayed in the format i would like it to be.
    I would like the current time from the instance of calendar i have created to be rounded to the nearest five up.
    The code i have for the combo box at the moment is:
         cal.set(cal.MINUTE, (int)Math.round((double)cal.MINUTE));
              n=0;
              int z = 0;
              while(z<288)
                   cal.add( cal.MINUTE, n);
                   s = DateFormat.getTimeInstance(DateFormat.SHORT).format(cal.getTime());
                   time_cb.addItem(s);
                   n=5;
                   z++;
    This code always sets the first value of the combo box to 10 minutes past the hour and increments it by five from there. This happened with all the other methods i tried from the other forums also.
    I would like it to round to the nearest five the current time and increment by five from this time.
    Thanks for your time and help.

    Hi,
    I have tried the various methods suggested on other
    forum messages but to no avail.
    I have a GUI that acts as the client for a reminder
    system i am making for some coursework.
    It contains a combo box with values for the user to
    select a time from, however the time is not displayed
    in the format i would like it to be.
    I would like the current time from the instance of
    calendar i have created to be rounded to the nearest
    five up.
    The code i have for the combo box at the moment is:
    Your first line is wrong. Your setting the calendar minutes field to
    some random value, cal.MINUTE, which has nothing to do with the current minute. You need to do
    Calendar c = new GregorianCalendar()
    which automatically sets the current minute
    cal.set(cal.MINUTE,
    (int)Math.round((double)cal.MINUTE));
              n=0;
              int z = 0;
              while(z<288)
                   cal.add( cal.MINUTE, n);
    s =
    =
    DateFormat.getTimeInstance(DateFormat.SHORT).format(ca
    .getTime());
                   time_cb.addItem(s);
                   n=5;
                   z++;
    This code always sets the first value of the combo box
    to 10 minutes past the hour and increments it by five
    from there. This happened with all the other methods i
    tried from the other forums also.
    I would like it to round to the nearest five the
    current time and increment by five from this time.
    Thanks for your time and help.

  • Rounding Time to nearest 30 minutes

    Good day,
    I'm looking for a way to round the time portion of a date value. My query needs to return the time of day, rounded to the nearest 30 minutes - top of the hour or bottom of the hour.
    If sysdate is: 12/28/2009 11:08:19 AM
    I need to see: 12/28/2009 11:00:00 AM
    If sysdate returns: 12/28/2009 11:18:19 AM
    I need to see: 12/28/2009 11:30:00 AM
    Any help is appreciated.
    Regards,
    Gary F.

    Aketi Jyuuzou wrote:
    I like case expression B-)Me too, but I like then simple B-) :
    with dates as ( -- generating sample data
    select to_date('12/28/2009 11:08:19', 'mm/dd/yyyy hh:mi:ss') dt from dual union all
    select to_date('12/28/2009 11:18:19', 'mm/dd/yyyy hh:mi:ss') dt from dual union all
    select to_date('12/28/2009 11:38:19', 'mm/dd/yyyy hh:mi:ss') dt from dual union all
    select to_date('12/28/2009 11:48:19', 'mm/dd/yyyy hh:mi:ss') from dual)
    select dt,
    case when to_char(dt,'mi') >= '45'
         then trunc(dt,'hh') + interVal '60' minute
         when to_char(dt,'mi') >= '15'
         then trunc(dt,'hh') + interVal '30' minute
         else trunc(dt,'hh')
         end as new
      from dates
    DT                  NEW
    2009-12-28 11:08:19 2009-12-28 11:00:00
    2009-12-28 11:18:19 2009-12-28 11:30:00
    2009-12-28 11:38:19 2009-12-28 11:30:00
    2009-12-28 11:48:19 2009-12-28 12:00:00
    SQL> SY.

  • Find average of 3 boxes to the nearest 0.50 inch.

    I am working on a PDF. I am trying to get the average of 3 numbers to the nearest 0.50 inch.
    So if the measurements were 16, 15, and 15 it would give the number 15.5 instead of giving the 15.33 since it is closer to 15.5 then 15.0
    Can someone help me with this problem?

    I have never done anything with Javascript before. So the values I am putting into the PDF are in field Neck1, Neck2, and Neck3. I want the average values in these 3 boxes to be put into field AvgNeck but rounded to the nearest 0.50 inch. I have tried to put your code in but I do not know how to get it to work since I don't understand how to get it to use the values I put into the fields and then get it to display. Please bare with me. I have tried to search online to see if I could figure out how to take your code and make it use my fields but i'm not currently understanding.

  • Needed to round a number to nearest thousand

    Hi all,
    Can any one say is there any function to round a number to nearest thousand.
    example == 73882 it must be rounded to 74000.
    Thanks
    Ravi
    use small case when you are posting the questions
    Edited by: Vijay Babu Dudla on Dec 15, 2008 12:09 PM

    Hi
    try this:
    DATA: V_IN TYPE I VALUE 73882,
          V_OUT TYPE I.
    DATA: V_1  TYPE I.
    V_1 = V_IN DIV 1000 + 1.
    V_OUT = V_1 * 1000.
    WRITE V_OUT.
    or
    DATA: V_IN TYPE I VALUE 73882,
          V_OUT TYPE I.
    DATA: V_1  TYPE I,
          V_2  TYPE I.
    DATA: V_DELTA1 TYPE I,
          V_DELTA2 TYPE I.
    V_1 = V_IN DIV 1000.
    V_DELTA1 = ABS( V_1 * 1000 - V_IN ).
    V_2 = V_1 + 1.
    V_DELTA2 = V_2 * 1000 - V_IN.
    IF V_DELTA1 < V_DELTA2.
      V_OUT = V_1 * 1000.
    ELSE.
      V_OUT = V_2 * 1000.
    ENDIF.
    WRITE V_OUT.
    Max

  • Rounding of Qty to the nearest whole no in PO

    Hi All,
    We have material whose base unit of measure is say centimetres. and it has purchase unit as metres.
    Our requirment for procurement is generated through MRP run which creates the Purchase requistion and in PR the UOM considered is the base unit of measure  ie centimetres.
    When this Purchase req is converted to Purchase Orders we get qty sometimes in decimals  for ex: if in Pur req the qty is 150 centimetres , in PO it is shown as 1.5 metres.
    Is there a way for rounding of 1.5 to 2.0 metres in PO (means to the nearest whole no) automatically.
    Thanks,
    Vengal

    in MRP view of material master you have two fields to care about rounding. rounding profile and rounding value
    http://help.sap.com/saphelp_46c/helpdata/en/f4/7d28c844af11d182b40000e829fbfe/content.htm

  • Rounding up to the nearest 0.05

    Hi guys i am trying to round a value up to the nearest 0.05. e.g. the value 94.63 would be rounded up as 94.65
    I have used big decimal with the round half up and round up modes but it still outputs 94.63
    How can I get arround this ?
    Cheers

          * Returns the value rounded up to the nearest 0.05
          * @param  double  value to be rounded
          * @return double  rounded up value
         private static double roundOff(double value)
              return Math.ceil(value / ROUNDUP_FACTOR) * ROUNDUP_FACTOR;
         }Where ROUNDUP_FACTOR = 0.05
    Edited by: fatjack on Dec 20, 2007 6:05 AM

  • Formulae - rounding down to the nearest five

    I am new to JAVA programming and not (yet) a brilliant mathematician. Can anybody tell me an algebra formula for rounding down to the nearest 5 (in 100)? Thanks in advance [email protected]

    Your question is not very clear.
    Still I think this would help
    //begin
    int remainder = number % 5 ;
    //We get the remainder
    number = number - remainder;
    //Trim down to the lower value
    if (remainder >= 3){
    number = number + 5 ;
    //If the remainder is 3 or more we should round to the higher value
    //End of block
    Hope this helps
    Shubhrajit

  • Data usage rounded up to nearest GB in Bill summary; Cannot download details as spreadsheet

    Two problems:
    1. Bill summary misrepresents data usage, rounding up to the nearest GB, for one of our 4 lines.
    2. Data detail "download to spreadsheet" does not work.
    My account has 4 lines. I have an old Family Share plan (no longer available) for 700 minutes; a "feature" for unlimited text; and individual data plans for each of the 4 lines. My daughter has a 2 GB data plan.
    Latest Verizon Wireless bill says my daughter used 1.0000000 GB of data. She didn't think so. I logged in to Verizon, went to "View Bill". then for the Bill Period: May 29, 2014 - June 28, 2014, I selected "Details for" > "DATA". I see all the usage by date and time; I can adjust the display from default "KB" to "MB". Then I clicked the link "Download to SpreadSheet ".
    Unfortunately, I get a file with only one line, just the headers, no data:
    "Date"    "Time"    "Usage Type"    "Description"    "Minutes"    "Application Price"    "Total"
    As a workaround, I can select and copy the data on the web page, then paste it into a spreadsheet program. I added a "sum()" formula and found that she used only 325 MB, not 2 GB.

    Does the bill say she used 1 GB or 2 GB? You had mentioned them both.
    As far as the usage, it's not too say she literally used that much but to say that she used that much or less. It may not matter since she has the 2 GB/$30 which means that you would be billed the same way either way.
    Your inability to download the spreadsheet may be due to an issue with your browser.

  • Rounding time to nearest hourly quarter

    I have several records like
    2/19/2010 1:25:46.000000 PM
    2/19/2010 1:40:46.000000 PM
    2/19/2010 1:55:46.000000 PM
    2/19/2010 2:10:46.000000 PM
    I want to round them off to the nearest quarter like
    2/19/2010 1:30:00.000000 PM
    2/19/2010 1:45:00.000000 PM
    2/19/2010 2:00:00.000000 PM
    2/19/2010 2:15:00.000000 PM
    Any ideas how I would do that? a trunc(col,'mi) only lets me round it to the minute..
    Note that records are not necessarily in the 5 minute interval difference it can also be 7 minute difference or 4 minute difference from the nearest quarter...
    so I can also have records like
    SysUpTime     2/19/2010 10:31:00 PM
    SysUpTime     2/19/2010 10:57:00 PM
    SysUpTime     2/19/2010 11:31:00 PM
    etc.
    Edited by: zebango on Mar 9, 2010 4:16 PM

    Solomon Yakobson wrote:
    But OP asked for "*Rounding* time to nearest hourly quarter". Same applies to Aketi's solution which, BTW, which always bumps it up to next 5 min.In which case, just substitute "Round" for "Floor"!
    Although thinking about it, you'd probably want to add seconds into the mix:
    with table_x as (select to_timestamp('11/03/2010 11:45:39', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:29', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:30', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:31', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:00:01', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:07:29', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:07:31', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 13:22:10', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 13:22:40', 'dd/mm/yyyy hh24:mi:ss') t from dual)
    select t,
           trunc(t, 'hh') + ROUND((to_char(t, 'mi') + (to_char(t, 'ss')/60))/15)*15/1440 nearest_15_min
    from   table_x
    T                                NEAREST_15_MIN      
    11/03/2010 11:45:39.000000       11/03/2010 11:45:00 
    11/03/2010 11:52:29.000000       11/03/2010 11:45:00 
    11/03/2010 11:52:30.000000       11/03/2010 12:00:00 
    11/03/2010 11:52:31.000000       11/03/2010 12:00:00 
    11/03/2010 12:00:01.000000       11/03/2010 12:00:00 
    11/03/2010 12:07:29.000000       11/03/2010 12:00:00 
    11/03/2010 12:07:31.000000       11/03/2010 12:15:00 
    11/03/2010 13:22:10.000000       11/03/2010 13:15:00 
    11/03/2010 13:22:40.000000       11/03/2010 13:30:00 

  • Rounding off to nearest value with formatNumber

    Can I use the formatNumber tag to round my numeric value to the nearest value?
    Like if it's 15.7 I would like to display 16
    And if it's 15.2, I would like to display 15
    I could successfully truncate by giving a patteren but Im not sure if I can round it off.
    Regards,
    Leena

    Yes you can - the following works on JSTL 1.1 / Tomcat 5.5 :
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <html>
    <head><title></title></head>
    <body>
    Test Auto Rounding of 16.8 :
    <fmt:formatNumber value="16.88" pattern="##"/>
    <br/><br/>
    Test Auto Rounding of 16.2 :
    <fmt:formatNumber value="16.22" pattern="##"/>
    </body>
    </html>Message was edited by:
    appy77

Maybe you are looking for

  • Itunes wont sync songs to ipod - didnt have this problem when i had xp

    this is the message i get - Attempting to copy to the disk 'RYAN'S IPOD' failed. You do not have enough access privileges for this operation iTunes could not save to your Music Folder because you do not have write access. Check the permissions on you

  • Deleted my iPod from home screen.

    I seem to have deleted my iPod shortcut/app from my home screen. Just wondering how I can get it back.

  • How do I sync my behance profile with creative cloud?

    I have a creative cloud membership and a seperate behance membership. How do I sync the two now that I get free membership to prosite?

  • Database retrieving records based on time stamp

    Hello all,                        I just  want to know that SQL query to retrieve specific time stamp record from the database using SQL server will work when same query is executed using SQL execute query.vi in labview.                       Its not

  • AR reserve invoice vs. inventory status

    To Experts, Can anyone tell me how to fix this inventory status? AR reserve invoice was created and paid, however a delivery document was created separately which leaves the inventory shows committed 10, and available -10. At the moment the item phys