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
Similar Messages
-
Excel import rounding up decimal values
In my excel file I have a column that contains dollars and cents (e.g. 49.95). When I run the import the values in this column are rounded up to the next integer (e.g. 49.95 is rounded up to 50). Is this a bug or am I doing something wrong?
Thanks,
PeterHi All,
I have already migrated lakhs of records and I am facing the same problem for decimal value migration. Shall I know whether anyone has fixed this problem? Is there any other free tool for SQL Server to ORACLE migration? Please do guide me as soon as possible.
Thanks,
Srinivasan.T -
Hi,can anyone please tell me how to round up a double type value to 6 decimal places.
Thank You!You should be able to adapt this solution I posted last week:
http://forum.java.sun.com/thread.jsp?forum=31&thread=412237
Changing the int's to double's will probably work fine.
Cheers,
Radish21 -
Rounding to decimal places in Captivate 6
I need some assistance with rounding to 2 decimal places in Captivate 6. Can this be done without scripting?
VinceRod or anyone
Would you be able to direct me to where I would be able to find the Javascript for rounding a variable to 2 numbers in Captivate 6?
Vince -
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 -
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 -
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 stopping rounding using decimal format
my problem is as
1. I am taking a double input in a jtextfield
2. Now i am using decimal format to round it to 6 decimal places
Now , how to make sure that decimal format while formatting do not round
like If input is 1.2345678 i want to get 1.234567 not 1.234568That's not really an SCCSE.
Anyhow, why not just use Double.parseDouble() if you don't want any rounding etc. Don't forget to catch the NumberFormatException:
parseDouble
public static double parseDouble(String s)
throws NumberFormatException
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
Parameters:
s - the string to be parsed.
Returns:
the double value represented by the string argument.
Throws:
NumberFormatException - if the string does not contain a parsable double.
Since:
1.2
See Also:
valueOf(String) -
hi,
i have record with value 237.741343124473. when user enter 237.7413431244, the record should return. i am using round function but is not working the way i want. is there any other function which can be used to round of the decimal pointsHow it is possible, because in my earlier reply i have added a same valued row in the test table and now when i am giving :
SQL> SELECT * FROM TEST WHERE TRIM(to_char(TRUNC(A, 12),'999.999999999999'))='237.741343124473';
A
237.741343
It is returning the row. Now you question will be why it is not returning the whole value? so for that:
SQL> SELECT to_char(a,'999.999999999999') FROM TEST WHERE TRIM(to_char(TRUNC(A, 12),'999.999999999999'))='237.741343124473';
TO_CHAR(A,'999.99
237.741343124473
Means, you have to apply to_char function on the column.Play around to_char,trunc functions; you can get your desired output.
Regards
Girish Sharma -
Hi,
I have a data field with data element 13 digits integer and 3 decimal points. But I want to display it with only 2 decimal points. I don't want to change the data element.
Eg: input = 100.438
required output = 100.44
if input = 100.434
required output = 100.43
Thanks in advance,
Vishnu Priyahi,
Just use this FM. it will give corect output.
DATA:
L_MENGE_P5(16) TYPE P DECIMALS 5,
L_MENGE_P3(16) TYPE P DECIMALS 2,
L_ANDEC like T006-ANDEC value 2.
L_MENGE_P5 = '56.4456'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = L_ANDEC
input = L_MENGE_P5 "over here u need to pass other than char
SIGN = '+'
IMPORTING
OUTPUT = L_MENGE_P3
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:/ L_MENGE_P3.
Regards
Anversha -
im trying to use decimal format and at the same time round numbers
code:
dformat = new DecimalFormat("0.0");
test = dformat.format(num);
but if num is .65 it just shows .6 when i need it to be .7
any suggestions.
thanksbecause it uses BigDecimal.ROUND_HALF_EVEN rounding mode, as per the API docs saying so......
... of course, for the life of me (I blame it on Monday.... yes, I know it's not Monday.... still) I can't remember the right way to do it..........
sorry..
brain freeze warning...
must go home and reboot.... -
Cant find method? and i cant figure out how to round a decimal....
when i compile this it says "getAverage not found in class AverageGradeUser" - look at actionPeformed() to find where its used at....how do i fix this, i had it working but somehow messed it up and when the new average is figured and put in the results textfield, how can u round it off to the nearest tenth (0.1)..ive tried using NumberFormat and related things but couldnt get it to work
please help me
thanks
p.s. keep in mind i am a rookie-rookie-rookie in java programming
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AverageGradeUser extends Applet implements ActionListener
/****InstanceVariables****/
public TextField input;
/*****InitMethod****/
public void init()
Label directions = new Label("Enter a grade percent: ");
input = new TextField(10);
Label results = new Label("Your new average is: ");
TextField output = new TextField(10);
add(directions);
add(input);
add(results);
add(output);
output.setEditable(false);
input.addActionListener(this);
} // init()
public void actionPerformed(ActionEvent e)
double grade = Double.parseDouble(input.getText());
if (e.getSource() == input)
getAverage(grade);
} // actionPerformed()
} // AverageGradeUser class
============================================================
(the classes are in separate files but both are in the project)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class AverageGrade
/****InstanceVariables****/
private double total = 0;
private double counter = 0;
private double average = 0;
private TextField input;
private TextField output;
/****ConstructorMethod****/
public AverageGrade()
/****AccessMethod****/
public void getAverage(double g)
total += g;
counter ++;
average = total / counter;
output.setText(average + " " + getLetterGrade(average));
input.setText("");
} // getAverage()
private String getLetterGrade(double avg)
if (avg >= 90)
return "A";
else if (avg >= 80)
return "B";
else if (avg >= 70)
return "C";
else if (avg >= 60)
return "D";
else if (avg < 60)
return "F";
else
return "error";
} // getLetterGrade()
} // AverageGrade classAccording to the code you have posted, method "getAverage()" is defined in class "AverageGrade" -- and not in class "AverageGradeUser". Therefore, you have two choices (in my opinion):
1. Add the definition of method "getAverage()" to class "AverageGradeUser"
2. Change the "actionPerformed()" method:
Replace the line:
getAverage(grade)with
new AverageGrade().getAverage(grade)Hope this helps you.
Good Luck,
Avi. -
Rounding of decimal values into XML using DOM
I want to roundoff 10.456 to 10.4(while generating the xml) using DOM.
Please let me know how to handle this?
Thanks in advanceread the java.lang.Math API
there are rounding functions there
and next time please just use a search engine -
Rounding of Decimal for dependent requirement During MRP Run
Hello Experts,
I have the following scenario:
We are currently enabling Characteristic Based Planning in our system.
Our one component is selected when two characteristic values are met through object dependencies.
Ex: Component A = Char A= '002' and Char B ='002'
Now we have given the following Usage Probability for the two characteristic:
Char A = 20%
Char B = 15%
And the total PIR quantity is 25 Pcs for Configurable Header.
With the above usage probability and PIR Qty, We have a dependent requirement of 0.75 Ea
((20% X 15%) of 25 Pcs) = 3% of 25 Pcs = 0.75 Ea of the component
Now during MRP Run I want to round the dependent Requiremnet to 1 Ea instead of 0.75 Ea.
Any suggestion towards the solution will be appreciated.
Regards,
VinodHi Vivek,
As mentioned we are using Characteristic Based Planning.
The component is selected based on a Selection comdition which is as follows:
Component 721290201000 = $PARENT.BCS_RL_LINE_LOADER = '002' and $PARENT.BCS_RL_WAFER_VENDOR ='002'
When the above two conditions are met the component is selected.
In Characteristic Based Planning we give percentages (Usage Probabality) to the characteristic values like:
$PARENT.BCS_RL_LINE_LOADER/'002' =20%
$PARENT.BCS_RL_WAFER_VENDOR/'002'= 30%
For the Parent which is a KMAT Material we maintain the PIR say 40 Qty.
Now the component qty is calculated as follows:
721290201000 =(20% X 30%) of 40 Qty of parent
721290201000 =(6%) of 40 Qty of parent
721290201000 = 2.4 Qty of component is the dependent req.
Now my requirent is to round the dependent requirenment to 3 during MRP Run. Please note that the purchase requisition got from the above dependent requirement is rounded to 3 qty.
Now I want to round the dependent requirement.
Regards,
Vinod -
Hi Guru,
Good day.
I have 5 output as bellow:
.15 2.2 1 .4 14.8 .43
I need to show them like bellow:
1 3 2 15 1
how can i get the desired output.
please help me.
With thanks
Moshiur
Moderator Message: Very basic question. Could be answered with a simple search and/or a few lines of code.
Edited by: kishan P on Sep 18, 2010 4:05 PMHi moshiur sohel,
Use FM 'ROUND' to round any value. Your scenario is of Positive rounding, for that give SIGN parameter as '+'.The following is the example code.
PARAMETER P_VAL TYPE P DECIMALS 2.
CALL FUNCTION 'ROUND'
EXPORTING
* DECIMALS = 0
INPUT = P_VAL
SIGN = '+'
IMPORTING
OUTPUT = P_VAL
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4
Close the thread if you have solved your query.
Thanks & Regards,
Rock.
Maybe you are looking for
-
I cant get my headphones to work on my laptop
I have a HP Pavilion dv2025nr notebook and I haven't been able to get my headphones to work since I changed my operating system to Vista Enterprise. Can anyone tell me what driver I need to dl to get it working again? I appreciate any and all help!
-
Is a ATI Radeon X1900XT (512 MB) card enough to drive a single monitor for video editing
My son just given an older mac pro. 2 x 3 GHZ Quad Intel Xeon. OSX Lion The video card installed is an ATI Radeon X1900XT (512 MB) Is this video card sufficient to drive a single monitor for video editing and basic graphics work in PhotoShop, etc? Ma
-
Java exception appear during file adapter to handle large xml
Hi,Guys, I am using file adapter to poll one folder of my local.one get input.xml,then do something,then write out output.xml. input.xml format is : <mes:DataRequestIns xmlns:mes="http://xml.netbeans.org/schema/MessageDefined"> <!--1 or more repetiti
-
Ho wto Dynamically Pass Parameters to a Query in Discoverer
Hi All, I have a Query where I would to like to pass the Parameters Dynamically.In my query I have three selects and two UNION ALL's.In the three selects I have to pass Period & Year Parameters.In Each Select the Period Calculation is Different.Say i
-
Hi, I create a very simple WSIF EJB binding, when running the BPEL process from the BPEL Console, I always got the "org.collaxa.thirdparty.apache.wsif.WSIFException: Class 'java.lang.String' is not compatible" error. =================================