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

Similar Messages

  • Rounding down using the floor function

    I need some help rounding down to the nearest 5 using the floor function.
    My code appears to be correct but I'm not getting the wrong result.
    create or replace
    TRIGGER "SALE_CALC" BEFORE
    INSERT OR
    UPDATE ON Prs FOR EACH Row
    BEGIN
    :New.Prsvf9c := (floor((:New.Prsprsc - :new.prsvf1c)/5)*5);
    END;
    *:New.Prsprsc = 100.00 and :new.prsvf1c = 46.00*
    After the trigger executes I get a result of *54.00*, which is the result before the rounding should take place. The result should be *50.00!*
    What am I doing wrong?

    The code you posted appears to produce the results you expect if the data is what you say it is
    SQL> create table prs(
      2    Prsvf9c number,
      3    Prsprsc number,
      4    prsvf1c number
      5  );
    Table created.
    SQL> create or replace
      2  TRIGGER "SALE_CALC" BEFORE
      3  INSERT OR
      4  UPDATE ON Prs FOR EACH Row
      5  BEGIN
      6
      7  :New.Prsvf9c := (floor((:New.Prsprsc - :new.prsvf1c)/5)*5);
      8
      9  END;
    10  /
    Trigger created.
    SQL> insert into prs( Prsprsc , prsvf1c )
      2    values( 100, 46 );
    1 row created.
    SQL> select * from prs;
       PRSVF9C    PRSPRSC    PRSVF1C
            50        100         46If you're seeing something different, it would be very helpful if you did something like I did here and post a reproducible test case.
    Incidentally, I'm not sure why you would have columns named prsvf1c and Prsvf9c but if that implies that you've denormalized your table to store 9 values rather than creating a child table with up to 9 rows, that's unlikely to be a reasonable solution.
    Justin

  • 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

  • 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

  • Formula for rounding down a number in a Pages WP table cell

    Could someone advise me on a formula? I know the answer might be straight-forward, but am not used to needing anything other than very elementary formulae, and cannot find a list in the Pages Help guide.
    I have a Pages WP document which contains a simple table. One cell is the sum of 4 others divided by 4, and is set to show 2 decimal points, e.g. 7.35, 6.75 etc. (This number is never above 9.00).
    I need this sum to always round down to the nearest .5 or .0, i.e. 7.35 would round down to 7.00, and 6.75 would round down to 6.50. (Simply limiting the decimal point to 1 doesn’t do it, because 6.75 would round up to 6.8).
    Any help much appreciated,
    Graham Falvey

    I would try with
    =ROUND(B*2,0)/2
    but I'm not sure that you really want that 5.25 returns 5.5
    Explanations about this kind of problem which are the same in Keynote, Numbers and Pages are available in the Numbers Guide.
    Yvan KOENIG (VALLAURIS, France) mercredi 2 septembre 2009 20:55:36

  • How do I Average two fields and round down?

    I need to average two fields and round down to the nearest whole number. The two fields will always each have a value.
    If someone could help me out, I'd appreciate it.
    T.

    Assuming you want this to be a custom calcuation script for a field, it could look something like this:
    // Custom calculation script
    (function () {
        // Get the field values, as numbers
        var v1 = +getField("text1").value;
        var v2 = +getField("text2").value;
        // Set this field's value to the average, rounded down
        event.value = Math.floor((v1 + v2) / 2);
    More information on the Math.floor method can be found in any decent JavaScript reference.

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

  • 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

  • Excise Duty-Round up or Round down

    Dear All
    The requirement is
    For eg, if ED amount is Rs 100.49, then system should round down to Rs 100/- ( in Excise Invoice & commercial invoice)
    If ED amount is Rs 100.51, then system should round up to Rs 101/-.                ( in Excise Invoice & commercial invoice)
    In other words, if the decimal is less than 50 paise, it should round down
                              if the decimal is more than 50 paise, it should round up.
    Any clue, on how its acheived?
    Thanking you.
    Rgds
    Sumanth.G

    Hi
    Check these notes to search possible causes:
    SAP Note 886532 - Pricing: Displaying and rounding numbers
    SAP Note 80183 - Rounding
    In the other hand, check if your condition is ruled by formula VOFM 016 or 017 (check your entries in table T001R)
    I hope this helps you
    Regards
    Eduardo

  • MATERIAL_UNIT_CONVERSION round down

    The qty on delivery is 31 EA and 1CS =12 EA for this item, so the qty. conversion would be 2.58 CS and because of the rounding down to the closest integer it should be 2 and not 3.
    Is it possible to round down the qty with FM MATERIAL_UNIT_CONVERSION?

    Use the command floor to round down.No need to use Func Module.
    d = 2.62
    x = floor(d) = 2 .

  • 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

  • My iPhone 4 shut down in the middle of a conversation and won't restart or charge. Any suggestions? The nearest Apple store is hours away from where I live.

    My iPhone 4 shut down in the middle of a conversation and won't restart or charge now. Any suggestions? The nearest Apple store is hours away and I depend on my phone to stay in constant touch with my child's specialist.

    I've tried that several times. It will not reset. The screen just stays black. I've never had this problem before. It usually resets the first time.

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

  • Rounding stroke thickness to nearest decimal?

    I have a project where many objects have been scaled up and down during the creation of the artwork. And I'm left with some lines that are .9581 pts and some that are 1.039 pts.
    Just because I'm a neat freak, is there a script that would round the stroke thickness to the nearest .1 decimal? Or whole number? Or user selectable amount of decimals?

    Navarro Parker,
    loop through your path items of selection. This is simple, if only path items in your selection exists:
    // StrokeThicknessRoundingNearestDecimal.jsx
    // required: one or more selected stroked pathItem(s)
    // Rounding stroke thickness to nearest decimal
    // https://forums.adobe.com/message/6764907#6764907
    // regards pixxxelschubser
    var sel = app.activeDocument.selection;
    for (i=0; i < sel.length; i++) {
    if (sel[i].stroked == true) {
        sel[i].strokeWidth = Math.round(sel[i].strokeWidth*10)/10;
    But much more complicated, if there are compound paths or e.g. grouped paths or nested grouped grouped … paths and not possible for strokes which are added in the appearance palette.
    Have fun

  • I am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going of

    i am using numbers in the new iWork. Just bought it 10 days back. I am not able to figure out how to add serial umbers from 1 to 100( for example) also i need to freeze the top header like in windows so that we can browse down without the heading going off. Can some one help?

    Hi Jay,
    Be aware that "Freeze Header Rows" and "Freeze Header Columns" apply only to rows and columns that are Header rows or Header columns. You can have up to five Header rows, Five Header Columns (and five Footer rows) on a Numbers Table.
    "Header rows" is a special designation. Besides being able to be frozen, Header and Footer rows are not included in formulas referencing whole columns, making it possible to place formulas such as =SUM(B) at the top (or bottom) of column B without causing a self-reference error, These designated rows are also not included in sorts of the rows in a table.
    Regards,
    Barry

Maybe you are looking for

  • How can I moving Closed Captioning from one stage video to another?

    Someone mistakenly included an MP4 video in a Captivate project. The project won't publish a SWF file (Your computer does not have sufficient memory resources to publish your file), and there are too many Closed Caption items on the stage video to re

  • Instead of an image i get a box with a blue square and white question mark help?

    Lately instead of images coming up I have been getting a blank box which in the center has a smaller blue square with a white question mark inside, does anyone have any suggestions.  Using safari version 8.0.3 on mac OX X Yosemite 10.10.2

  • Problem while deploying an ear

    Hi,   i have a problem in deploying an ear which contains an ejb and with a web service which is already deployed in another ear.The error is   "Web service already exsits in the http service provider for that ear". Now i need a solution for this pro

  • Update button not showing up on 3rd gen ipad

    App store showed some updates so I clicked 'update all' button.  Everything was updated except for two apps. I was going to update them manually but noticed that both apps didn't have the Update button. I was using IOS 7.0.6 when I did the updates. 

  • Saving files in editor

    Whilst trying to save an edited file in editor I get the following message. Could not build a preview because of a program error. Im using imac