473,464 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2111
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: 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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.