A double with 2 decimal places
I need to output a double that has 2 decimal places. The default is just one and I don't know the command to make it two. For example,i want an output of 37.5 to be displayed as 37.50. If you know the command, please tell me. Thanks!
Looks like you are trying to deal with money.
Firstly if you are dealing with money store everything as the lowest form of currency in your given area. eg as pence or cents and place it in a int or long. That way you dont get any rounding erros when you multiply up the value.
To put two decimal places on a number is easy just use a DecimalFormat from java.text
Like this
double myNumber = 3.1;
DecimalFormat decF = new DecimalFormat( "######0.00" );
String myFormattedNumber = decF.format( myNumber );
System.out.print( "My number is " + myFormattedNumber ); The #######0.00 in the DecimalFormat constructor call is a pattern that is used to format the number. The # indicate an optional number the 0 indicates a required number and if one is not provided a 0 will be included.
Similar Messages
-
Problems with decimal places and formatting
Hi , we are having problems with an add on running on different localization companies. Decimal places separatd by "," differ from other localizations. We dont know if this is a SQL collation setting or somethng related to code or requirements to run add ons on different servers and languages.
Any ideas??
ThanksHello
Follow up with this thread:
[Re: How to get the numeric value of DocTotal from UI API]
Regards,
J. -
Select amount field of a table with decimal place of 3rd value grater than 0.
Select all the reord in a table with amount decimal place of 3rd value grater than 0.
Can you show the sample data + desired result?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Change IDR currency with decimal place
Dear Guru,
Currently in my SAP env, IDR currency setting is set with 0 decimal place.(No decimal Place). However, I have user requirement to change the setting from zero to 2 decimal place. Meaning to say, to have IDR currency maintain in 2 decimal place. What is the effort and is this a big change to the system ? is this change workable ? How will this impact the existing historical data which store IDR amount with no decimal place ?
Hope to hear from you.
Regards
Andrew TayDear Guru,
Thank you for your replied. I totally agreed with you, currently my SAP system can maintain up to 15 digits with no decimal place. Beside this digits isues, is there any other areas affected ?
Thanks in advance.
Regards
Andrew Tay -
Download amount value without decimal place but element with decimal place
Hi all,
to display the amount without decimal places in classic report, i can use this way which is wa_wrshb NO-ZERO CURRENCY wa__waers.
may i know,
1) how to display amount in ALV where amount value (which using dmshb/wrshb) has no decimal place like JPY?
2) what should i do if i want to download the amount value which field using dmshb or wrshb that the value has no decimal place like JPY?
ThanksHello,
You can display the ALV output according to the decimal point in the currency.
When creating the field catlog for the amount field add the currency parameter also.
wa_fieldcat-fieldname = <amount_field>.
wa_fieldcat-tabname = <output_table>.
wa_fieldcat-seltext_l = <column_heading>.
wa_fieldcat-outputlen = p_olen.
wa_fieldcat-currency = wa_waers. " This will work same as CORRENCY wa_waers
Regards
DKS -
Calculated field with decimal place
Hello,
if I create calculated field in a table using formula e.g., ColumnName/ 60, where format of ColumnName is INT (total ammount of minutes) in order to get hours, I get only integer part, not decimal. E.g., 80 (minutes)/60 =1.3333 but, in calculated field
I see only 1 hrs without possibility to change format of the field.
Can calculated field be used on this way? (My wish is to get 1.3 in that field)
How?
ThanksOf course the calculated field/column can not be an INT, if it is then change that.
Does something like this work?CAST(ColumnName/60 AS Decimal(10,2)) -
Query to find records with more than 2 decimal places
I have written the below query to find records with more than 2 decimal places, but it is returning records with decimal places 1 & 2.
The datatype of the AMT column is NUMBER (without any precision).
SELECT amt FROM amount_table
WHERE substr(amt, instr(amt, '.')) LIKE '.%'
AND length(substr(amt, instr(amt, '.') + 1)) > 2Output:-
AMT
*41591.1*
*275684.82*
*64491.59*
*3320.01*
*6273.68*
*27814.18*
*30326.79*
131.8413635
162.5352898
208.5203816
8863.314632
22551.27856
74.716992
890.0158441
2622.299682
831.6683841
*1743.14*
2328.195877
3132.453438
5159.827334
3.236234727
37.784
ThanksOracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
create table amount_table
LINE_NUMBER NUMBER not null,
FEE_AMT NUMBER not null
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60208, 41591.1);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60213, 275684.82);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (60238, 64491.59);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (63026, 3320.01);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (59906, 6273.68);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (83111, 27814.18);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (83114, 30326.79);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112395, 131.8413634682);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112399, 162.5352898104);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112402, 208.5203815738);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112403, 8863.3146321954);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112406, 22551.2785551322);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112407, 74.716992);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112410, 890.015844079);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112411, 2622.2996817048);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112414, 831.6683840698);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112415, 1743.14);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112418, 2328.1958771886);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112419, 3132.4534379886);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112422, 5159.8273341686);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112423, 3.2362347266);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112426, 37.784);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112427, 198.7423503696);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112430, 0.7220848332);
insert into amount_table (LINE_NUMBER, FEE_AMT)
values (2112433, 12.4149375254); -
Suppress decimal places in OBIEE Year column prompts
Hi gurus,
I don't know its a bug or what , in our database the "Year" columns comes without any decimal places ,also in the criteria section of the report ,I have made the data format "with '0' decimal places ", but still in the column prompt in the dashboard , I am getting year value with decimal places .
Eg. 2012 coming as 2012.00 in choice list of the prompts . Can you provide me any work around? for that thanks in advance..The problem is due the data type of the column . Go to the physical layer and check the data type . It would be of 'Double' data type .. Change it to 'Int' data type. This would solve the problem . Posting it for the benefit of others who face similar issues. let me know if it helps anyone..
-Jay -
I'm developing a C++ library with oracle OCI library. I'm loading from a Oracle Database 11g database. Here I need to load large values with decimal places. In this case I need to use long double instead of double. I'm not sure whether OCI supports for long double.
According to the documentation SQLT_FLT is for float and double only. Can someone let me know whether OCI supports for long double and if so how to retrieve themHi,
The problem with SQLT_FLT is that the Oracle client fetches the value as NUMBER and then performs the conversion to the native double/long double type.
NUMBER is not supporting the full IIEE double range of values.
That why Oracle introduced in Oracle 10g the BINARY DOUBLE SQL type that can be fetched using SQLT_BDOUBLE / native host long variable. Thus the all range of C double and long double values can be used within OCI.
Regards,
Vincent -
Error while updating decimal places in general settings
Hii All
I have got an error while updating Decimal places in General Settings
Cannot update while another user is connected to the company i have checked, there is no other user logged in, i could add other settings but the problem is only with Decimal Places
Note : there are no postings yet, a fresh database for a new client
what could be the possible reason
thanks
RIYAZHiii All
As a forum rule, i have initially gone through with the existing threads and then i was force to post a thread,
would be helpfull if there is any other way..
Thanks
RIYAZ -
Decimal Places are not Permitted for Chile Country
Hi All,
In OVA8 settings for Chile country at the field max.doc value, i am not able to use the decimals. getting error message as Decimlas are not permitted (Message no - 00011). checked OY04 - there is no decimals for Chile currency. checked - OY01 Dec.Pt. format as 1.234.567,89
For Argentina, Peru and Uruguay same settings has been done and i am able to save the decimal points in OVA8 at the field max.doc value.
Please let me know if there is any specifis settings for Chile or SAP NOTE
Thanks,
MaheshHI,
just looking at a brand-new ECC60 / EhP4 system where nobody changed OY04 settings.
I can find CLP (Chilean Peso) in the list with ' ' decimal places, so thats why there are no decimal places allowed.
Check again OY04, if you find an entry for CLP and NOTHING is maintained it means that ZERO dec. places are allowed.
If you find an entry in OY04 with a number of decimal places >0 than this decimal places are allowed.
If there is NO entry for a given currency then its used with 2 decimal places (SAP standard).
So OY04 is only for the currencies that should be treated different as SAP standard.
Best regards, Christian
Edited by: Christian Ortner on Feb 3, 2011 5:09 PM -
Error in Decimal places.
Hi Experts,
my client is using ECC 5.0 now we have the problem with decimal places when the customer posts the transaction with USD,the problem is rising. For Ex: If the PO is raised in USD 500,but the system is updating only as 50 USD.
Your valuable advices will be appreciated.
Thanks & Regards,
Vasu.Hi,
Please check the user specification maintenance in SU01 t.code and select the Tab of Default and change the Decimal Notation. -
Hi
In MD04 , we are getting decimals for the quantity. Is there any settings or config change involved to remove display of
decimals.
Regards
ManiDear,
If the database contains an amount with decimal places for an MRP element, the system also displays this value this way in MD04, because this is the value relevant for MRP purposes.This does not depend on the settings for the unit of measure in transaction CUNI (table T006).In case of values without decimal places, the system displays the value according to the setting in the unit of measure (T006-DECAN).Therefore, the decimal places of the MRP elements can vary. Check CUNI setting for rounding the values.
Regards,
R.Brahmankar -
I have created a user defined table (udt).But it does not accepts float value.For entering float values I change the data type of the alphanumeric.How do I accept number with decimal places without changing it to alphanumeric ?
HI Dilip,
Set the Type and SubType propertied correctly.
When you create an UDF, please check, that
oUDF.Type = BoFieldTypes.db_Float
oUDF.SubType = BoFldSubTypes.st_Quantity
Regards,
J, -
Hi
I have this SQL code for a pie chart and it rounds items down to 0% instead of showing decimal places. Is is possible to change it to show 0.5% for example?
select null link, PRODUCT label, 100*ratio_to_report(COUNT(ID)) over () value
from CHART_BY_PRODUCT
WHERE REGION = NVL(REPLACE(:P17_REGION, '%null'||'%', NULL), REGION)
AND LOB = NVL(REPLACE(:P17_LOB, '%null'||'%', NULL), LOB)
AND TRUNC(TO_DATE(DATECALLED)) BETWEEN TRUNC(TO_DATE(:P17_FROM_DATE))
AND TRUNC(TO_DATE(:P17_TO_DATE))
group by PRODUCT
order by count(id) descRegards
AdamBasically this function - 100*ratio_to_report(COUNT(ID)) over () - is showing values in percentage. i.e. 40%, 20%, 5%, 1%, 0%.
I want it to show the percentage with decimal places i.e 40.52%, 20.3%, 5.2%, 1.25%, 0.25%
Can I change the function somehow to show two decimal places?
Thanks
Adam -
Decimal Places In VDT Measures
hi experts,
i have a small problem with decimal places.
i'm using the UMC_CPM_STRAT to customize my Measures and VDTs
i have created measures using 0QUANTITY and defined 0.00 in the decimal places field.
after a while i have changed all the measures of the tree to 0 in decimal places
now i've changed back to 0.00 but my measures do not change
when using the UMV_PRES my measures has no dec' places like it is still using 0 and not 0.00
have i forgotten something along the way?
need your help
thank you,
Or.hi all,
i was able to solve the problame of the decimal places display in my vdt.
first i have changed it in tge measure attr' in the transaction UMC_CPM_STRAT -> Measures
since i am working with a bps definitions i have found that i need to change it also in the transaction BPS0 -> Planing Area -> Planing Level -> ad-hoc Package -> Menual Planning -> change layout
in the layout def's you can choose the number of dec' places.
for your knowledge.
Best Regards,
Or.
Maybe you are looking for
-
Mavericks Crashing once or twice EVERY hour!! Help
Hi, I'm really struggling with my mac. It's crashing around every half an hour or so and I have no idea why. Ive taken it into the Apple Shop- no hardware issues, Ive done a complete re-install and transferred settings back on via migration assistant
-
Ipad mini not recognised by windows xp
My computer with windows xp is saying my device is undetectale.Why? Could the program be to old although apple recommends windows xp?
-
IPhone 4 AirPrint printing issue (AirPrint Installer 1.3 for Windows)
I have been trying to get AirPrint working on my iPhone 4 (CDMA/Verizon) for a while now without success I know that the AirPrint feature is designed to work with AirPrint compatible HP WiFi printers (as Apple dropped support for OS X), though I have
-
Macbook screen not aligned to base
Hi guys, I purchased a new MBP from Apple's website and noticed that the screen is not aligned to the base. It do not look normal at all as the laptop itself is not fixed properly. May I know if I can get help from anywhere to fix the issue? This is
-
Premiere Elements 11 (Trial) question
Hello What might be the reason why Premiere Elements 11 (Trial) will not open up when I double-click on its desktop icon? I have successfully installed it today - but not used it - and I can see it in the Control Panel and there is a folder for it un