Rounding Function Query
Hi All, Currently I would like to round off to 2 Decimal for a double value.
Below is my code:
DecimalFormat df = new DecimalFormat("#0.00");
String result = df.format(1.345);
However, the result turn out to be "1.34" instead of "1.35". If the double value is "1.3451", the result is "1.35". For the other input value, the rounding works fine. Hence, can anyone out there know why there is such a behaviour and how I can resolve this issue? Really appreciate if someone can response to my query.
Thank you.
But 1.5 is rounded to 2 with that code...... that code referring to
DecimalFormat df = new DecimalFormat("#0");
String result = df.format(1.5);Where was this code posted besides here?
Any obvious
reason why?DecimalFormat seems to round using BigDecimal.ROUND_HALF_EVEN
You are rounding to the nearest int, so that is either 1 or 2, since 1.5 is exactly between those numbers, it picks the even number, 2.
I think there was a request to change this to round the way people normally think to round.
:) Is this good timing or what?
http://developer.java.sun.com/developer/qow/index.jsp
Similar Messages
-
How to return whole number using round function
hi
can i get sql query using round function how to return whole number valueHi welcome to the forum. if you want whole number value what does it mean
1. whether you want the whole number greator than or eqaul to that number example for 12.6 you want 12 or 13
see below example
1. SQL> select round(12.5) from dual;
ROUND(12.5)
13
2. SQL> select round(12.4) from dual;
ROUND(12.4)
12
3. SQL> select floor(12.5) from dual;
FLOOR(12.5)
12
4. SQL> select floor(12.4) from dual;
FLOOR(12.4)
12
floor will always give you a round value which is a integer or whole number less than or equal to but output of rond will differ if the value is greator than 12.5 it will give 13 but if it is less than 12.5 it will give 12, so depending on your requirement you can choose which function to use. similarly if you always want to get the whole number greator than the number you can use ceil as below
SQL> select ceil(12.3) from dual;
CEIL(12.3)
13
SQL> select ceil(12.8) from dual;
CEIL(12.8)
13 -
Issue with ROUND function in RTF template
Hi All,
Can anyone please help me in implementing the ROUND function at the RTF template.
Need to handle rounding of amounts at the RTF template level itself.
The ROUND function should be implemented to the following tags:
<?sum(current-group()/TAXABLE_AMOUNT)?> (Record level)
<?sum(TAXABLE_AMOUNT)?> (Report level total)
Eg. If the Sum(current-group()/TAXABLE_AMOUNT) for a particular record is 401.65 then it should round of to 402
we try to do this using following syntax ..
1) by declaring variable "value"
<?xdoxslt:set_variable($_XDOCTX, value, sum(current-group()/TAXABLE_AMOUNT))?>
2) <?xdofx:round(sum(current-group()/TAXABLE_AMOUNT))?>
3)<?xdofx:round(xdoxslt:sum(current-group()/TAXABLE_AMOUNT))?>
but we ding get the solution.
A quick response on this is highly appreciable.
Thanks,
PraveenRe: Summing derived values within xdofx:
Re: Rounding not working -
How to Create a Functiona Query
Dear all,
Could any body detail me how to create a functional query. Please give me step by step procedure to create a query.
I would appreciate if you can give me a material with screen shots. Your help will be highly appreciated.
Thank you
Raghu RamHi Raghu,
Go through this document it may help you,
SAP Query
Step 1: Create User Group SQ03
Follow the menu path SAP Menu > Tools > ABAP Workbench > Utilities > SAP Query > User Groups
a) In the User Group: Initial Screen -
Enter User Group Code (self named)
Click on Create
b) In the User Group (Code): Create or Change pop-up window -
Enter the User Group Description
Click on Save
c) In the Create Object Directory Entry pop-up window -
Ö Click on Local Object button
Ö The User Group Created is saved
Step 2: Create User Group SQ02
Follow the menu path SAP Menu > Tools > ABAP Workbench > Utilities > SAP Query > Infosets
a) In the Infoset: Initial screen -
Ö Enter Infoset Code (self named)
Ö Click on Create button
b) In the Infoset: Title & Database Screen -
Ö Enter Description of Infoset in the Name field
Ö In the Data Source selection: Select appropriate Data Source by clicking
the radio button
· Source the data can either be multiple tables OR single table. There are 4
options for the user to select from
Ö Click on Continue (Enter)
Ö Selected Table gets displayed in the Infoset : Initial Screen
c) In the Infoset: Initial Screen -
Ö Click on Insert Table button
d) In the Add Table Screen -
Ö Enter the Table Name that is to be inserted
Ö Click Continue (Enter)
e) In the Infoset: Initial Screen -
Ö Click on Back button
f) In the Field Group Defaults pop-up Screen -
Ö Select Appropriate Field Group Option by clicking on the radio button
· there are 3 options to select from. User can select Empty Field Group
option and then select the data fields in the steps explained further.
Alternatively, User can select an option which clubs all the data fields
From all the tables selected
Ö Click Continue (Enter)
g) In the Change Infoset Screen -
· the left side lists the Tables that the user has selected in step b, c & d
· In the right side, system creates field groups, one for each table listed in the
left part. Initially, the Field Groups are empty
Ö In the Left Side, Click on the arror next to the table name and expand and
display all the data fields in the table
Ö Select a Data Field from the expanded Table view, which is to be added to
the Field Group on the right.
Ö Select a Field Group on the right side, in which Data Field selected above
has to be added
Ö Right click on the Data Field selected and click on Add Field to Field Group
Ö The selected Data Field gets added to the selected Field Group, which is
indicated by an arrow next to the Field Group.
Ö Carry out the steps above to add the required Data Fields to the respective
Field Groups
Ö After transferring Data Fields to Field Groups click on Generate button
h) In the Create Object Directory Entry Screen -
Ö Click on Logical Object button to generate the infoset
i) In the Change Infoset Screen -
Ö Click on the Back button
j) User is taken back to the Infoset: Initial Screen which displays the
created Infoset record.
Step 3: Assigning User Group to Infoset SQ03
Follow the menu path SAP Menu > Tools > ABAP Workbench > Utilities > SAP Query > User Groups
a) In the User Groups: Initial screen -
Ö Enter the User Group for which Infoset is to be assigned
Ö Click on Assign Users & Infosets button
b) In the User Group: Assign Users Screen -
Ö Click on Assign Infosets button
c) In the next screen, select the Infoset, which needs to be attached to the
User Group selected
d) Click on the Back button
Step 4: Creating Query SQ00 & SQ01
Follow the menu path SAP Menu > Tools > ABAP Workbench > Utilities > SAP Query > Queries
a) In the Query from User Group: Initial Screen -
Ö Click on Other User Groups button
Ö In the pop-up screen, User Groups, select the User Group for which the
Query has to created. The pop-up screen closes.
Ö Enter the Query Code in the Query field
Ö Click on Create button
b) A pop-up screen Restrict Value Range shows the list of Infosets assigned to
the User Group
Ö Select the Infoset for which Query has to be created
c) In the new screen Create Query: Title, Format -
Ö Enter the Description of the Query in the Title field
Ö Click on the Next Screen button
d) In the Select Field Group screen
Ö Select the Field Groups from which Data Fields have to be selected for the
Output
Ö Click on the Next Screen button
e) In the Select Field screen -
Ö Select the Data Fields, which should appear in the output
Ö Click on the Next Screen button
f) In the Screen Selection -
Ö Select the Data Fields for the selection criteria
Ö Enter the sequence in which the selected fields would appear in the input
screen of the query.
Ö Define if the selection criteria should be Single Value or Multiple Value Range
by clicking in the appropriate check boxes
Ö Click on the Basic List button
g) In the screen Query Layout Design -
Ö Select the Output Fields from the Data Fields section by clicking the
appropriate check box
Ö Change the sequence of Data Field columns if required
Ö Click on the Test button to test the query created
h) On the Test Query screen click Continue
i) In the Query screen -
Ö Enter the selection criteria
Ö Click on Execute button
j) Save the Query created
Step 5: Running the Query SQ00
a) In the Query From User Group: Initial screen
b) Click on Other User Groups button to select the User Group
c) In the pop-up screen User Groups select the User Group
d) System lists all the queries created for the User Group
e) Select the appropriate Query
f) Click on Execute button
g) User is taken to the Selection screen
h) Enter the selection criteria and click on Execute button
i) System runs the query and gives the output
Regards,
Murali. -
Using sum function and round function in single text form field
Hi all,
I have a column Name - A . In the rtf template i have summed up the column A and showing it. But the output is coming as 99.9999997. I want to round it to 100.
I tried using <?round(sum(A),2)?> but dint workout.
I also tried using variables. It is also not working.. I used <?xdoxslt:set_variable($_XDOCTX,’ABS',sum(A)?> and then i used get variable to get it.... But it throwing error while using sum in the set variable step.
Can anyone please help me..
Thanks
SunilHi Sunil,
Calculate the sum into a Variable. and apply round function on the variable to get the desired value.
Calculating sum:
<?xdoxslt:set_variable($_XDOCTX,'v',xdoxslt:get_variable($_XDOCTX,'v')+DOLLARS)?> (its running sum formula,should be placed inside the table to get sum of all rows of particular column)
here Variable 'v' holds the sum value
apply round function:
<?round(xdoxslt:get_variable($_XDOCTX,'v'))?>
Thanks and Regards,
Aravind -
Problem with the round function using Date
Hi,
I have a problem with round function for Date. The input is the four digit year which was picked out from say SYSDATE.
In these scenarios the original value should be rounded up and should get the output as shown under rounded column.
Scenario1
Original Rounded
2020 ---> 2020
2021 ---> 2020
2022 ---> 2020
2023 ---> 2020
2024 ---> 2020
2025 ---> 2025
2026 ---> 2025
Scenario2
Original Rounded
2020 ---> 2020
2021 ---> 2025
2022 ---> 2025
2023 ---> 2025
2024 ---> 2025
2025 ---> 2030
2026 ---> 2030
Scenario3
Original Rounded
2020 ---> 2020
2021 ---> 2020
2022 ---> 2020
2023 ---> 2025
2024 ---> 2025
2025 ---> 2025
2026 ---> 2025
Can anyone help with this....Urgent Please
Thanx for your time1.
SQL> select n,n-mod(n,5) rnd from test;
N RND
2020 2020
2021 2020
2022 2020
2023 2020
2024 2020
2025 2025
2026 2025
2.
SQL> select n,n+(case when mod(n,10) = 0 then 0
2 when mod(n,10) < 5 then 5-mod(n,5)
3 else 10-mod(n,10)
4 end) rnd
5 from test;
N RND
2020 2020
2021 2025
2022 2025
2023 2025
2024 2025
2025 2030
2026 2030
7 rows selected.
3.
SQL> select n,n+(case when mod(n,10) < 3 then mod(n,10)*-1
2 when mod(n,10) < 8 then 5-mod(n,10)
3 else 10-mod(n,10)
4 end) rnd
5 from test;
N RND
2020 2020
2021 2020
2022 2020
2023 2025
2024 2025
2025 2025
2026 2025
2027 2025
2028 2030
2029 2030
2030 2030
11 rows selected. -
My colleague (using Word 2003) and I (using Word 2007) are working on a change to a template where we include a formula that has the function called rounding.
She (2003) is able to preview the pdf but I (2007) am getting error message: : oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'round'
All other settings that we have appear to be the same (same config file, same java version, etc)
Does anyone know if there are some changes to Word 2007 that are causing this? And, any ideas on how to resolve?
Thanks for the help!
Background:
-The function is designed provide a total weight value: each individual weight value, multiply by a factor of .80, round up, and then added together to get a total amount.
-Because we also show the individual weight values on the output, (also multiplied by the factor of .80 and then rounded up), we need the factor and rounding to happen before the sum).
The entire set of functions for the total weight value is:
<?xdoxslt:set_variable($_XDOCTX,'sum',0)?>
<?for-each:LIST_G_CONTAINER_NAME1?><?for-each:G_CONTAINER_NAME1?>
<?xdoxslt:set_variable($_XDOCTX,'sum', xdoxslt:get_variable($_XDOCTX,'sum')+ xdoxslt:round((GROSS_WT*0.8),2))?><?end for-each?><?end for-each?>
<?format-number: xdoxslt:get_variable($_XDOCTX,'sum');'9G990D00'?>
space
<?WEIGHT_UOM_CODE?>
Error when attempting to preview the pdf after uploading an xml file:
: oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'roundHi,
I took my original file (didn't have the round functionality) and Word 2007 and did the following:
1) Tested with xml to ensure that there are no other issues - was able to preview successfully
2) Added the function you suggested: <?xdoxslt:round(1000.98978,2)?> and saved the change
3) Tried to preview using the same xml and got the same error message about rounding
I can't test on 2003 because my colleague is not working right now (she is the one with that version installed). I will try on 2003 later today (but I am guessing it will work for her because the other rounding function works for her).
Thanks for any other ideas about this.
Here is the entire extract of error message:
Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
Run XDO Start
RTFProcessor setLocale: en-us
RTFProcessor setConfig: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdo.cfg
FOProcessor setData: C:\Data\BI Publisher\2010_CR-102626_PL-CML_Net Weight\Net Weight Template Changes\Testing\OTST_SC-06_PL_SGS-2903194_Direct_ENG_Jul-09.xml
FOProcessor setLocale: en-us
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(Unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
at RTF2PDF.runRTFto(RTF2PDF.java:632)
at RTF2PDF.runXDO(RTF2PDF.java:466)
at RTF2PDF.main(RTF2PDF.java:254)
Caused by: oracle.xdo.parser.v2.XPathException: Extension function error: Method not found 'round'
at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1526)
at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:517)
at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:485)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:264)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:150)
at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:187)
... 16 more -
Combing rounding functions with other functions
I am using hyperion reports. Is it possible to combine a rounding function with another function? Specifically, I am taking a variance of actual vs budget where actual and budget are % of total functions. The variance I am getting is off (see ex. below.) I need to keep the actual and budget at 1 decimal point. To correct this problem in excel I am able to round the numbers pulled in by essbase. The ex. below illustrates my problem. Actual .2% Budget .2% Variance .1%
You may want to make a 'Scenario' for rounding that is rounding the input data. If you make it (variance) 2pass, it will show the difference of the rounded numbers (ie. 0%)Rich [email protected]
-
Error: [msnodesql] Invalid passed to function query
i create a schedule.
I try to run this code:
var todoItemtable = tables.getTable('TodoItem');
var item = {text:"blahblah"};
todoItemtable .insert(item, {
success: function() {
console.log('Inserted event: ', item);
or this:
var sql = "select * from TodoItem";
mssql.query(sql, {
success: function(results) {
console.log('Success: ', results);
}, error: function(err) {
console.log('Error: ', err);
but always get an error: [msnodesql] Invalid passed to function query. Type should be .
What is the problem? What am I doing wrong?Mal,
I think that need to provide more information about what you are doing when you get this error. This appears to be a LV error.
1)What version of LV are you using? What are you doing in TestStand when you get this error?
2)Is your TestStand sequence calling a VI from which this error is generated? If so what is this VI doing?
3)Can you isolate the source of this error to a particular VI that is using queues?
4)How often does the error occur?
5)The path of Queue Core.vi is \vi.lib\Platform\synch.llb\Queue Core.vi. Can you put some probes on the input of this VI to determine what inputs are causing this error? What are all of the inputs to this VI when the error occurs?
6)Is queue being created or destroyed? Is an element being added or removed from a que
ue?
7)Is this your queue or a queue used by one of LV's VIs?
Unless someone has had this exact error, then it is going to be difficult to debug without more information. Clearly, the problem is easiest to solve if it is reproducible by others. -
Native compilation and the ROUND function
Native Compilation Advisor lists the built-in ROUND function as not supported for natively compiled stored procedures. Is there a suggested workaround?
oracle by oracle wrote:
I am trying to test performance of one package and there is only one procedure wich uses just instr and substr internal functions ( I am working with varchar2).
I am having the folowing results: native compilation is twice worst than inetrpreted. What may be the reason?
P.S. I did ALTER SYSTEM FLUSH SHARED_POOL;Yuo should take this into account that the Native compilation is not supposed to make the code always go faster. If I remember correctly, the maximum benefit that Oracle benchmarked for it was about 30% only and taht too, if the code has lots of computational code rather than queries. If your package contains lots of this kind of code. than may be the Native compilation may be faster than the other but it doesn't come with any guarantee like this.
Have a read about it from here,
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2278
HTH
Aman.... -
Hi Experts,
Can you help me in finding a suitable round function in SAP? I need to round off to 3 decimal places. I used the function module ROUND but it is not very much helpful.
I have 3 values ex 0.43444567 , 0.0824495 , 0.48310483. The total is 1. But wen i update in transaction Kp46 for Plan value column it takes only 3 decimal places. So if i reduce the above 3 values to 0.434,0.082,0.483 then i get total as 0.999.
But if i reduce them ( rounding off ) to 0.435,0.083,0.483 i get 1.001. Please help me get a proper solution for this.
Thanks and Regards,
Ramya SHi,
Thanks for your reply. But I need not calculate the sum to update it anywhere. I just want the total to be 1. I just want to reduce them to 3 decimal places and also retaining the the total as 1.
Thanks,
Ramya S -
How the ROUND function helps to solve balancing accounts?
As a developer, I'm being assigned to solved a bug in an application. In the application, large number transactions with credit and debit amounts are to be balanced. But before balancing, another calculation takes place. At the end of that calculation, the difference between the credit and debit amounts is not zero. There'll be a difference of about 0.02. Thus an application error is raised.
Will there be a possibility of making use of the ROUND function and solving it? or are there any other functions provided by Oracle to solve such a situation?
ThanksI guess, you should post here steps of example calculation. It also depends on the organization which rule it is following, I mean something like ignoring few decimal places etc.
Please post the example. -
Self-join query to Analytical function query
Hi All,
I have converted a self-join query to Analytical function query due to the performance reasons.
Query which is using Analytical function is giving the correct count as I compared it with query using Self-Join. Can you please tell what is wrong in the query.
==========================
Query using Self-Join
select count(1)
From (select t1.*, max(t1.dw_creation_dt) over (partition by t1.empl_id) pers_max_date
from ohr_pers_curr t1 ) pers
, (select t2.*, max(t2.dw_creation_dt) over (partition by t2.empl_id, t2.empl_rcd) job_max_date
from OHR_JOB_CURR t2) job
where pers.empl_id = job.empl_id
and pers.dw_creation_dt=pers.pers_max_date
and job.dw_creation_dt=job.job_max_date
and job.dummy_row_flag = 'N'
and pers.dw_creation_rsn_cd in ('N', 'U')
and job.dw_creation_rsn_cd in ('N', 'U')
================================================
Query Using Analytical function
select count(1)
From (select t1.*, max(t1.dw_creation_dt) over (partition by t1.empl_id) pers_max_date
from ohr_pers_curr t1 ) pers
, (select t2.*, max(t2.dw_creation_dt) over (partition by t2.empl_id, t2.empl_rcd) job_max_date
from OHR_JOB_CURR t2) job
where pers.empl_id = job.empl_id
and pers.dw_creation_dt=pers.pers_max_date
and job.dw_creation_dt=job.job_max_date
and job.dummy_row_flag = 'N'
and pers.dw_creation_rsn_cd in ('N', 'U')
and job.dw_creation_rsn_cd in ('N', 'U')
==================================Hi David,
The base is same but the problem is different.
As far as implementation concern these queries looks same, but when I see there counts, they do not match. I do not have any reason why this happening.
Regards
Gaurav -
BPEL round function with precision for a decimal value?
Dear All,
I need to do a rounding of a higher value to 3 precisioned one.
As per the round function available in Jdeveloper, I can only round a decimal to its respective integer value.
But my requirement is to retain the decimal value, but with a limited precision value...
How can I accomplish this.. Is there any extension of round function in BPEL to do this...?
Please update..
Many thanks...Use the function format-number(variable,precision_num)+.
Thanks,
Sen -
Hi everyone, can someone please help me with a function to use here please. I have a nine digit number e,g (000046650 and 024063870). I would like to convert this to 4 digits before the comma and 5 digits after the comma. So it must be something like this (0000,46650 and 0240,63870). I thought I could easily do this with a ROUND function, but it doesn't work. Could somebody please help by telling me what I'm missing?
Thank you all for your help.Hi,
I must be missing something, but why don't you just divide by 10000 ?Scott@my11g SQL>with d as (
2 select 000046650 n from dual
3 union all
4 select 024063870 from dual
5 )
6 select n/10000 from d ;
N/10000
4.665
2406.387You can then use a to_char with fmt to format it with zero padding :Scott@my11g SQL>with d as (
2 select 000046650 n from dual
3 union all
4 select 024063870 from dual
5 )
6 select to_char(n/10000,'0000.00000') nn from d ;
NN
0004.66500
2406.38700
Maybe you are looking for
-
IDOC-XI-XML Scenario Questions
Hi everyone, I am actually trying to configure a scenario starting from SAP and finishing creating a XML file. R/3 IDOC -> XI -> XML file The XI is receiving IDOCs from SAP correctly, but when it try to send to third party system, the monitor engine
-
After I restart orabpel and hw_services all deployed processes disappeared
Hello All, I have restarted the hw_servces and orabpel applications from the enterprize manager then all the deployed bpel processes are disappeared from the BPEL Console. How to bring them back ? Thanks Saikrishna
-
Question about 'all images' in finder
i was wondering why when i was looking in 'all images' in the finder, there were doubles of allllll of my images?
-
I cannot type anywhere in Firefox
This has happened twice, and both times I could not pinpoint a cause. Currently, I cannot type in any field of Firefox (address bar, google bar, websites, nothing). I am running 17.0.1, and have no add-ons. I have tried restarting the computer, re-in
-
Adobe Reader XI not recognizing Outlook as a default mail client! Help!
Reader XI keeps telling me that there is no default mail client... when in fact Outlook is the default mail client! I have unistalled & re-installed reader xi... still same propblem. Working on a Windows 7 computer with Outlook 2013.