473,324 Members | 2,567 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,324 software developers and data experts.

number of decimals

Hey,

how can I set the number of decimals?

Example:
5 decimals 2.12345
2 decimals 2.12

I've found something about NumberFormat in the API, but without an example I
can't solve this...

Thanks in advance,
Oswald
Jul 17 '05 #1
3 5621
nfDollars = NumberFormat.getInstance();
nfDollars.setMaximumFractionDigits(2);
nfDollars.setMinimumFractionDigits(2);
double ss = 1.2323;
String s = nfDollars.format(ss).toString();

"Oswald" <fl*********@hotmail.com> wrote in message
news:3f***********************@reader2.news.skynet .be...
Hey,

how can I set the number of decimals?

Example:
5 decimals 2.12345
2 decimals 2.12

I've found something about NumberFormat in the API, but without an example I can't solve this...

Thanks in advance,
Oswald

Jul 17 '05 #2
I had to wait till i got home to answer this one, didn't have my docs on me
at work.

This is what i used when i needed to format things a specific way

DecimalFormat money = new DecimalFormat("$###,###,###.00");

then when ever you need to format something just do

money.format(value);

i belive you need to import java.text.* for that one

hoped that helped
Nick


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #3
Thanks guys,

this really helped me out!
"Oswald" <fl*********@hotmail.com> wrote in message
news:3f***********************@reader2.news.skynet .be...
Hey,

how can I set the number of decimals?

Example:
5 decimals 2.12345
2 decimals 2.12

I've found something about NumberFormat in the API, but without an example I can't solve this...

Thanks in advance,
Oswald

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andreas Emmert | last post by:
Hi there, I'm trying to import a csv file into my MySQL database. Unfortunately the number format for the price column is formatted in German style, i.e. XX,XX (decimals separated by comma not...
2
by: SoLRaC | last post by:
I have a form, and i want with javascript round a number with 2 decimals to de uper next 0 or five. IE if you have the number 4,53 it must be rounded to 4,55. Until now i wrote that var valor...
37
by: Protoman | last post by:
Hi!!! Protoman here, I need to write an infinite precision number class b/c I want to compute pi. Give me some sample code. Also, when I run my program and it computes pi, will my computer freeze...
9
by: Johnny Lee | last post by:
Hi, Pls take a look at this code: ---------- >>> t1 = "1130748744" >>> t2 = "461" >>> t3 = "1130748744" >>> t4 = "500" >>> time1 = t1+"."+t2 >>> time2 = t3+"."+t4
6
by: Donal McWeeney | last post by:
Hi, Is there a way to specify on the predefined format strings like P and N that you want displayed all the decimals in the number... for example 3 will display 3 2.1 will display 2.1...
4
by: Dimos | last post by:
Hello All, I need some help with random number generation. What I need exactly is: To create a few thousand numbers, decimal and integers, between 5 and 90, and then to export them as a...
4
by: Chris Davoli | last post by:
The folllowing will round to 526, but it should round to 527. It works correctly for all other numbers, except for this one. Does anybody know of a bug in Math.Round? Dim ldecWater As Decimal =...
52
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
6
by: TSGB | last post by:
Hi, I have a Table which has 2 Double, Fixed Number fields to 3 decimal places. This fields are populated as the result of 2 division operations which lead to multiple decimals (the numbers...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.