Rounding a decimal number up

I have a field where the final answer comes up as a decimal and the client wants the final answer for the employee to see to be a whole number, but he wants it rounded up, no matter what the decimal answer is. Is there a way to do that?

The script could be something like:
// Custom calculation script
(function () {
    // Get the field values, as numbers
    var v1 = +getField("Average of scores").value;
    var v2 = +getField("Text 4").value;
    // Perform the calculation, round up to nearest integer, and set this field value
    event.value = Math.ceil(v1 * v2);
For more information on the Math.ceil method, see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil

Similar Messages

  • Round decimal number to two places

    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.
    -tried using math.round but it only rounds to nearest integer
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to double
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?
    any advice is appreciated:)

    coynerm wrote:
    trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.Agree.
    -tried using math.round but it only rounds to nearest integerI advise against rounding in most newbie situations. Usually it's the display of the variable you want to change.
    -tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to doubleOf course cast won't allow you to convert back. If you wanted to do that you'd use Double.parseDouble(stringVar); But we don't know why you are doing all this converting in the first place.
    *is there a round method that allows you to specify decimal places?
    *or is there an easy method to cast a string back to a double?Advice: Forgetting all this fooha with rounding, what in essence are you trying to achieve? Why all of this number manipulation in the first place? It will affect what should be the best answer.

  • Regarding Converting the Decimal number into rounded value...

    Hi,
       i have a decimal number as "   58240990.00 " , i wanted this to rounded value .
      for example I am expecting to see 58241 for the above number.
      shell we can do in any way.. if so please let me knw fast.. it is urgent..
      thanks in advance.
    thanks,
    Suresh..

    Dear Suresh,
    Go through the following code chunk:
    DATA : p TYPE p DECIMALS 2 VALUE '2.49'.
    DATA i TYPE i.
    i = CEIL( p ).
    WRITE : i.
    Regards,
    Abir
    Don't forget to award Points *

  • Rounding off 2 decimal number

    Hi,
    How can i round up float number to two decimal number.
    For example
    Number is 45.987654532 then It should be rounded up to 45.98
    Number is 45.987654546 then It should be rounded up to 45.99Appriciated sample souuce (If any)
    Tanks in advance

    You could have a look at String's format() method. The format strings are
    described in detail here:
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.htmlpublic class Round {
        public static void main(String[] args) {
            double number = 45.987654546;
            String roundStr = String.format("%.2f", number);
                // Rounded is 45.99
            System.out.println("Rounded is " + roundStr);
                // The same thing
            System.out.printf("Rounded is %.2f%n",  number);
    }Note: these methods generate rounded Strings from floating
    point numbers. Also, they round to a string representing the "nearest"
    number - your first example is a little hard to understand in this regard.

  • Rounding a decimal value to 3 digits

    I have opened a UDF and copied the value of Total (LC) column in that field. I want to round off the copied value to 2 digits.
    Below is the query written to copy the value.
    SELECT ($[$38.21.NUMBER] * $[$38.U_GST.1.11]) / 100
    Below is the query written to ROUND the value.
    SELECT ROUND(($[$38.21.NUMBER] * $[$38.U_GST.1.11]) / 100, 2)
    Thanks & Regards,

    Try: SELECT ROUND(($[$38.21.NUMBER\] * $[$38.U_GST.NUMBER\]) / 100, 3)
    However, I think it is probably not working because B1 has internal checking to make sure the decimal value follow your setting. If you setup your currency by 2 decimals, you may never get any additional decimal place.
    Thanks,
    Gordon

  • Rounding a decimal to 1 up

    Hi All ,
    I need help in rounding a decimal to intezer up by one value ,
    i.e 1.001 to rounded to 2 .
    Thanks and regards
    vinay

    Hi,
    plz try ROUND function module.
    data input type p decimals 3 value '1.001'.
    data output type i.
    CALL FUNCTION 'ROUND'
      EXPORTING
       DECIMALS            = 0
        input               = input
       SIGN                = '+'
    IMPORTING
       OUTPUT              = output
    EXCEPTIONS
      INPUT_INVALID       = 1
      OVERFLOW            = 2
      TYPE_INVALID        = 3
      OTHERS              = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write: output.
    thanx .
    Edited by: Dhanashri Pawar on Sep 22, 2008 9:21 AM

  • Question about rounding a decimal

    Hi, I've got a requirement that says that if I've got a decimal number, say,
    16.15446
    I should display it as 16.16
    The values I'm provided with will always have 5 decimal places.
    If I'm provided with 16.15552, I should display it as 16.16 too.
    obviously I tried:
    select round(16.15446,2) as test_value from dual
    TEST_VALUE
         16.15
    1 row selected.But obviously it's not what I expected.
    Any suggestions?

    Actually, that's probably the "correct" answer.
    0.15446 is closer to 1.5 than it is to 1.6, so rounding down to 1.5 is the 'right' thing to so.
    But if your rounding rules are different, something like this might do:
    select case when mod(substr(16.15667,5,1),2)=1 then round(16.15667,2) else round(16.15667-0.01,2) end from dual;You obviously need to substitute in appropriate values all the way through that, but if you plug in 16.15552, you get:
    SQL> select case when mod(substr(16.15552,5,1),2)=1 then round(16.15552,2) else round(16.15552-0.01,2) end from dual;
    CASEWHENMOD(SUBSTR(16.15552,5,1),2)=1THENROUND(16.15552,2)ELSEROUND(16.15552-0.0
                                                                               16.16And for your original number:
    SQL> select case when mod(substr(16.15552,5,1),2)=1 then round(16.15552,2) else round(16.15552-0.01,2) end from dual;
    CASEWHENMOD(SUBSTR(16.15446,5,1),2)=1THENROUND(16.15552,2)ELSEROUND(16.15446-0.0
                                                                               16.16

  • How to convet a decimal number of in to base 64.

    Hi friends,
    my requirement is how to convet a decimal number of in to base 64.
    ex:decimal number could be any type 1,1.2,-1,-1.2 etc
    i found an API Base64.java but iam not able to use .
    Please Help me out.

    try this
    Typecast your array of integers to Byte[] and use method byteArrayToBase64() as:
    String encodeArray = Base64.byteArrayToBase64( new byte[]{ 3, 34, 116, 9 } );Also, browse the below link for more details
    http://kickjava.com/src/java/util/prefs/Base64.java.htm
    Message was edited by:
    Mayank_03

  • I can't use a decimal number in a update routine

    Hi,
    I want to use a decimal number in a udate routine (in a updating rule). I've a code similar to this:
    IF COMM_STRUCTURE-/BIC/ZSATIAUX1 LT 1,5.
      RESULT = 'GOOD'.
    And when I save the routine I get the following error:
    E:Comma without preceding colon (after IF ?).
    The COMM_STRUCTURE-/BIC/ZSATIAUX1 field is numeric field with three decimal positions.
    Can anybody tell me why I can't use decimals in my routine?
    Thanks in advance.
    Regards.

    Hi,
    Try following code:
    Data: Val type COMM_STRUCTURE-/BIC/ZSATIAUX1 .
    val = 1.5.
    IF COMM_STRUCTURE-/BIC/ZSATIAUX1 LT val.
    RESULT = 'GOOD'.
    endif.
    Regards,
    Geetanjali

  • Comma or point in decimal number

    Hi,
    I wonder how to handle decimal number input from jsp page with comma or point. Is there a way to take care of this automatic so a comma get parsed to a point or vice versa.
    Thanks in advance.

    I don't know if it will be a comma or a dot that is inputed. My keyboard uses a comma on the numeric pad but if i change it to a US keyboard it will use dot instead so I can't tell what a user will input. And if I understand everything when java calculates a double it has to be with a dot, or am I completly wrong.
    So with this in mind i decided to replace all dots with a comma and then parse it to a double with NumberFormat and do my calculation and then format it with NumberFormat again. This works fine and gives me a nice output if no one tries to input more than one point or comma.
    I can't think of another way to do it so if this is completly wrong so please point me in the right direction.

  • How to convert fractional decimal number to hex number?

    Hi,
    Can any one help me to convert the fractional decimal number to its equivalent hex number and vice versa ?
    if u have any code please share.
    thanks
    neethu

    neethukk wrote:
    Can any one help me to convert the fractional decimal number to its equivalent hex number and vice versa ?
    if u have any code please share.
    This question is not clear at all.
    "Fractional decimal" is not a data type, but a way of formatting in readable form using numeric characters and a decimal separator.
    Same to "hex number", but only for integers.
    What do you mean by "convert"? Do you want to keep the value the same or retain the bit pattern of the numeric data type?
    Hexadecimal is for integers. Are you talking about fixed point?
    We clearly need significantly more information. What are the input and output data types? What are you actually trying to do?
    Do you have an example input and corresponding output?
    LabVIEW Champion . Do more with less code and in less time .

  • Round up float number

    Hi,
    I have to manage floats with euro format .
    here's the code :
    <CODE>
    float first = 78.31;
    float second = 1.81;
    float tot = first + second;
    </CODE>
    the result of thi addition is tot = 80.11999......
    sigh!!
    how can i round up this number with 2 digits of precision ?
    (tot = 80.12)
    thx

    You don't. But you can format it rounded. (i.e., the stuff in the java.text package, like DecimalFormat).
    Or you can represent the value using ints. (E.g., create a Euro class and have two ints, one for the whole euro value and one for the fractional euro value.
    Or you can use java.math.BigDecimal.
    This issue keeps coming up. Check the forum for a recent thread about fractions.

  • Round up a number .

    Hi
    Can any one tell me how can i round up a number .
    for example :
    23.80   to 24
    23.30  to 23 .
    Regards
    Rakesh singh

    >Joy to the Workbench, the Search is come!
    >Let ABAP receive her Guru;
    >Let every thread, first search for it,
    >And search and search again,
    >And search and search again,
    >And search and search, and search again.
    >
    >Joy to the Search, the Round is found!
    >Let ABAPers their F1 deploy;
    >While fields and tables, functions and methods,
    >Round up and down with joy,
    >Round up and down with joy,
    >Round up, and down, and round with joy.
    >
    >No more let sins and guests grow,
    >Nor spam infest our second home;
    >Abuse report buttons, let them flow to mods,
    >Far as the curse is found,
    >Far as the curse is found,
    >Far as, far as, the curse is found.
    >
    >Still points-hunters come again,
    >And make of themselves a pain.
    >The repeated answers, go on and on and on,
    >Until the thread is locked,
    >Until the thread is locked,
    >Until, until... the thread... is... locked!

  • How to convert data read in byte to decimal number?

    The following are a source code to read from a serial port, but i can't convert the data that i read to decimal number and write it on a text file.....can anyone kindly show me how to solve it? thanks
    import javax.comm.*;
    import java.io.*;
    import java.util.*;
    public class Read implements Runnable, SerialPortEventListener {
         // Attributes for Serial Communication
         static Enumeration portList;
         static CommPortIdentifier portId;
         SerialPort serialPort;
         static OutputStream outputStream;
         InputStream inputStream;
         Thread readThread;
         public static void main(String s[])
         portList=CommPortIdentifier.getPortIdentifiers();
         while(portList.hasMoreElements())
              portId=(CommPortIdentifier)portList.nextElement();
              if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL)
                   if(portId.getName().equals("COM1"))
                        System.out.println( portId.getName());
                        Read ss=new Read();
              }     // end of while
    }          // end of main
    public Read()     {
    try{
              serialPort=(SerialPort)portId.open("Read", 2000);
    catch(PortInUseException e)     {}
         try{
              inputStream=serialPort.getInputStream();
              System.out.println(inputStream);
    catch(IOException e)     {}
         try{
              serialPort.addEventListener(this);
    catch(Exception e)     {}
              serialPort.notifyOnDataAvailable(true);
         try{
              serialPort.setSerialPortParams(9600,
              SerialPort.DATABITS_8,
              SerialPort.STOPBITS_1,
              SerialPort.PARITY_NONE);
              }catch(UnsupportedCommOperationException e)     {}
              readThread=new Thread(this);
              readThread.start();
         }//end of constructor
         public void run()
              try     {
                   Thread.sleep(200);
              }catch(InterruptedException e)     {}
         public void serialEvent(SerialPortEvent event)
              switch(event.getEventType())
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                   break;
                   case SerialPortEvent.DATA_AVAILABLE:
                   byte[]readBuffer=new byte[8];
                   try{
                        while(inputStream.available()>0)
                             int numBytes=inputStream.read(readBuffer);
                             //System.out.println("hello");
                        System.out.print(new String(readBuffer));
                        }catch(IOException e)     {}
                   break;
                   }     // end of switch
                   try     {
                        inputStream.close();
                        }catch(Exception e5)     {}
         }          // end of serialEvent

    Is it a float or a double?
    For a float, the decimal should be 4 bytes (small numbers like 1.1 start with the byte 0x40). Convert these 4 bytes to an int, using byte-shifting would probably be easiest.
    int value = ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);//b# are bytesNow to convert it to a float, use
    Float.intBitsToFloat(value);Now if you want double percision, You will have 8 bytes instead of 4, and need to be converted to a long instead of an int through byte-shifting. Then use Double.longBitsToDouble(long bits) to get the double

  • Removing leading spaces in a decimal number

    I have a decimal number field of length 28 with 9 spaces.I have to print it right justified and remove the leading spaces.I appreciate if anyone can let me the statement for this

    Hi,
      Try this..
    DATA: V_P TYPE P DECIMALS 2.
    V_P = '112.00'.
    WRITE: / V_P.
    DATA: STR TYPE STRING.
    STR = V_P.
    SHIFT STR LEFT DELETING LEADING SPACE.
    WRITE: / STR.
    Thanks,
    Naren

Maybe you are looking for

  • [solved] stable network card name eth0 eth1

    Hello, I'm new to Arch Linux. I have two Ethernet interface adapters, let's distinguish them by their MAC addresses MAC0 and MAC1. Relationship between MAC addresses and 'eth' unit numbers may change after reboot. Sometimes MAC0~eth0 MAC1~eth1 someti

  • Installing PHP on FMIS 3.5

    I've recently installed and set up a FMIS 3.5 setup and my web developer wants to have php on the server to create some dynamic content.  Trouble is, I can not for the life of me get PHP to work on the server.  Is there some special instructions that

  • Inclusion of LiveCycle Designer with Acrobat Pro 8.0

    Are there any restrictions to LiveCycle Designer that's furnished with Adobe Acrobat Professional 8.0 ? I've checked the validity of my copy of Acrobat Pro 8.0, including the installation S/N, with Adobe Customer Service. After Installation and activ

  • 10.3.9 and mobile me

    Can some one explain to me what is going on. I have had my imac for over three years running 10.3.9 and safari 1.3.2 Apple does not offer a version of safari to upgrade to. Yet safari runs on windows? With this older imac I do not want to upgrade my

  • TS4036 When I backed up my phone I lost the ringtones I had downloaded and paid for, how do Iget them back

    when I backed up my phone I lost the ringtones that I purchased how do I retrieve them?