473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Big decimal nearest integer value

karthickkuchanur
156 100+
Expand|Select|Wrap|Line Numbers
  1. BigDecimal bigDecimal = new BigDecimal(10.85);
  2.         System.out.println(bigDecimal.intValue());
In this i found result of 10 but i expextesd nearest int like 11
if the input id 10.21 it should be 10,there is no method in bigdecimal please give me suggession

Thanks
karthick
Jan 12 '10 #1
2 7599
Markus
6,050 Expert 4TB
What about the BigDecimal.round() method?
Jan 12 '10 #2
karthickkuchanur
156 100+
Expand|Select|Wrap|Line Numbers
  1. BigDecimal bigDecimal = new BigDecimal(10.17);
  2.         double value = bigDecimal.doubleValue();
  3.  
  4.         System.out.println("DOUBLEVALUE"+bigDecimal);
  5.         int finalValue = (int)Math.ceil(value);
  6.         System.out.println(String.valueOf(finalValue));
My problem get solved there no method like round
there is only variale lile ROUND_UP,DOWN etc ,i am using java1.4
Jan 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Peter Blatt | last post by:
Does 5 represent the total numer of digits (including the fractional portion) or only the number of places BEFORE the decimal point? Moreover does the number include the decimal point? Are there...
7
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3",...
22
by: hantie | last post by:
In my program, for reducing the complexity, the integer was stored as char, so 2 is stored as '2', which is decimal: 50 Is is possible for me to obtain the integer value of '2' in the program,...
2
by: Alper Özgür | last post by:
Hi; I want to convert a decimal to integer. but the problem is i wanna do convert the value to upper integer value if there is decimal value... For example if value is 12,01 this must convert to...
1
by: mdawoodk | last post by:
i am getting error "input string was not in correct format" when converting a string decimal into integer value. code is like this: string strVal = ""; int nVal = 0; strVal = "14.9"; nVal...
2
by: Mr. Ken | last post by:
Here are the funny results I got from Dev-C++, what I need is rounding to nearest integer. How can I do that in Dev-C++? a = -1 -1 -1 -1 1 1 2 2 2 1 b = round(a) -0.729627 -0.9540721...
2
by: poopsy | last post by:
how do i round a value to the nearest integer? im doin that inside a function
1
by: poopsy | last post by:
how do i round a value to the nearest integer?
6
by: phpmagesh | last post by:
Hai friends, {$PRODUCTS_PRICE} This is my variable i dont know why they used { } for that. in that product_price i m storing a integer value like 112.00 etc.., when i change to another radio...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.