473,320 Members | 2,161 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,320 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 7595
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.