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

Formatting a double

Ok so I have this number 1.4316557653333333E9 and I need to format this number so I can print out 1431 million 655 thousand and 765

Here is my curent code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. import java.util.*;
  4. public class numberthree {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         double DAY , space , mill , thou , hund; 
  9.  
  10.         Scanner keyboard = new Scanner(System.in);
  11.  
  12.         System.out.println("Please input the number of days MyMail has been running :");
  13.         DAY = keyboard.nextDouble();
  14.  
  15.         space =  ( (( 512 * Math.pow(2, 20) )/ 15 ) * DAY ) + (1024  * Math.pow(2, 20)) ;
  16.  
  17.  
  18.         System.out.println(space);
  19.  
  20.              mill = space / 1000000;
  21.              thou = space % 1000000;
  22.              hund = space % 1000;
  23.  
  24.  
  25.         System.out.printf("Email storage space (in bytes): " +  "%.2f" , mill + "million" +  thou +  "thousand" + hund);
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.     }
  34.  
  35.  
  36.  
  37. }
  38.  
Thanks for the help!
Sep 22 '11 #1
0 1598

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

Similar topics

0
by: bojanraic | last post by:
Hi! I am about to submit an article on a PHP-based site (BBCode is used for formatting), and I have a formatting problem: I am not sure how to print double quotes (" "). I tried some character...
3
by: Keith | last post by:
Ok, so here is the code I have so far........my question is whether it is possible to hold onto the amount of hours for each car entered without erasing it through the next entry. I need a table...
2
by: Homer Simpson | last post by:
Hi, I'm looking for a way to format the output of my double value. For example, the result of a calculation may be 12.3456789 but I want to display 12.346 (three decimal places of precision)....
2
by: Carlos | last post by:
Hi all, just wanted to know how can I just quickly round to nearest 100th, and use the first two decimal places of a double value in a textbox, instead of all the decimals. Thanks in advance,...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
1
by: bsmith1111 | last post by:
I have a program that outputs the following to the screen (through visual c++) 9999999999, which is stored in a double. I would like to keep the number the way it is, but every time I output it...
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
11
by: Ole Nielsby | last post by:
First, sorry if this is off-topic, not strictly being a C++ issue. I could not find a ng on numerics or serialization and I figure this ng is the closest I can get. Now the question: I want...
2
by: Derek Hart | last post by:
I have a double stored in a DataTable: dt.Rows(i)(MergeFieldName) I want to format this and store it into a string. I have formatting stored in a database, such as "$#,##0.00"
13
by: cj2 | last post by:
pages = 1 pages.tostring gives me "1" pages+1.tostring gives me "2.0" Why did it add the ".0" on there? I was looking for "2" and this screws me up. Actually this is what I was doing. In...
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: 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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.