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

How to convert an int to a string with a fixed point?

I'm trying to output a time. I have an int representing the hours and the minutes. Both need to be two digits, and they need to be output as string variables.

How do I output the numbers with two places?
For example, assume that
int hour = 8, int minute = 5
I need to make string timeOutput = 8:05
I thought it was
timeOutput = ("{0:D2}:{1:D2}", hour, minute);
But that doesn't work.
Mar 24 '11 #1
1 1846
GaryTexmo
1,501 Expert 1GB
You've almost got it, you're just missing the call to string.Format.

Expand|Select|Wrap|Line Numbers
  1. timeOutput = string.Format("{0:D2}:{1:D2}", hour, minute);
Mar 25 '11 #2

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

Similar topics

5
by: Abe Simpson | last post by:
Hello all, The application I am working on must never output numbers in a floating-point format, that is, something like 2e-002 is a big no-no. At the same time, it must output numbers in a...
1
by: tribal | last post by:
Hi guys, How can i convert a string to a point I had a point as a string in the first place eg : Point myPoint = new Point(12,12); string s = myPoint.ToString();
9
by: pout | last post by:
What are the purposes of fixed-point? When should it be used? I read: #define Int2Fixed(x) (((long)(short)x) << 16) and the fixed-point in 16.16 format. Does the 16 in the MACRO refer to...
2
by: Pallav | last post by:
I'm trying to convert some source code containing floating point into fixed-point arithmetic. I am having some trouble understanding fixed point signed multiply. I have a 18.14 base integer with...
0
by: pallav | last post by:
is anyone aware of a freely-available C fixed point library for unix/linux systems? i remember about 6-7 months ago, i searched the net and located a project (i'm not sure now if it was open...
4
by: riya1012 | last post by:
hello guys, I need some help from you. I am doing a DSP project and for that I need to do some C coding for the conversion of sample data which is in floating point representation to fixed point...
9
by: suppamax | last post by:
Hi everybody! I'm writing a C program for a PIC18F microcontroller. I need to calculate a power function, in which both base and exponent are fixed point numbers (ex: 3.15^1.13). Using...
2
by: m.a | last post by:
Hello, Is there any fixed point library in .net framework? I need it to use on fixed point processor that doesn't have any floating point co processor Regards
0
by: dugi | last post by:
How convert real fixed point number in two bytes (s,2^6...2^0), (2^-1...2^-4) to single float number. Dugi
1
by: dugi | last post by:
How convert real fixed point number in two bytes (s,2^6...2^0), (2^-1...2^-4) to single float number. Dugi
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
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
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...

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.