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

how do i get the number to display only 2 decimal places?

there is a valve that is being written to a tag and it displays a very long number. how do i get the number to display only 2 decimal places?
Oct 26 '10 #1
1 2108
Dheeraj Joshi
1,123 Expert 1GB
Use DecimalFormat to specify number of decimal places.

Expand|Select|Wrap|Line Numbers
  1. double d = 5.678965
  2. DecimalFormat dF = new DecimalFormat("0.00″);
  3. dFormat.format(d));
  4.  
Regards
Dheeraj Joshi
Oct 27 '10 #2

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

Similar topics

6
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly...
3
by: shez | last post by:
Hi, Is there any way to output a double value with different number of decimal places (apart from using 'sprintf'). I looked up the reference for C++ streams and found the 'setprecision'...
29
by: Gaijinco | last post by:
Sooner or later everytime I found recreational programming challenges I stumble with how I test if a number is has decimal places differnt than 0? For example if I want to know if a number is a...
3
by: android | last post by:
I require a function that takes a double as a parameter and returns the number of decimal places. What is the most efficient way in c# to find out the number of decimal places I have written a...
17
by: scan87 | last post by:
Can somone please, please give me the solution for the following problem. I need to submit it on Monday. Write a global function called format, which formats numbers with a given number of decimal...
3
by: Sean | last post by:
So I have a web form that accepts temperature readings...and sometimes the reading is a round number (ex. 74), and other times its not (ex. 58.3). I have the database setup to accept numeric(4,1),...
3
by: mattlightbourn | last post by:
Hi, I hope you're all well. I need to right justify some figures in a list box and the only way I seem to be able to do it is by using the number as text and doing something like this in a...
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...
3
by: jamesnkk | last post by:
I have a currency field Total_Amount in the form,it display at 2 decimal places, but if i click on the field, it display 4 decimal places. How do I not show 4 decimal places but only show 2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.