Re: String Format

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 02/27/04


Date: Fri, 27 Feb 2004 14:13:38 -0000

Mike Ruane-Torr <mike.ruane-torr@USE_EVENS_ixwiflaoyn.net> wrote:
> Thank you for that! I've been going round in circles in the .Net help
> file trying to work out how to do it. Am I right in saying that it
> doesn't exactly mention it anywhere, or have I missed it?

No, it does. Look at "standard numeric format strings":

<quote>
Standard numeric format strings are used to format common numeric
types. A standard format string takes the form Axx where A is a single
alphabetic character called the format specifier, and xx is an optional
integer called the precision specifier. The format specifier must be
one of the built-in format characters. The precision specifier ranges
from 0 to 99 and controls the number of significant digits or zeros to
the right of a decimal. The format string cannot contain white spaces.
</quote>

and then in the "X" specifier:

<quote>
The number is converted to a string of hexadecimal digits. The case of
the format specifier indicates whether to use uppercase or lowercase
characters for the hexadecimal digits greater than 9. For example, use
'X' to produce "ABCDEF", and 'x' to produce "abcdef". The precision
specifier indicates the minimum number of digits desired in the
resulting string. If required, the number is padded with zeros to its
left to produce the number of digits given by the precision specifier.
This format is supported for integral types only.
</quote>

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • format & %e notation problem...
    ... I want to present a vast amount of real numbers in as fewer space as ... I use format with the %e format specifier. ... but it seems there is no way to limit the number of z digits. ...
    (comp.lang.tcl)
  • Re: Custom date format not working in ACC2003
    ... It forces the year to display as 4 digits in dates, ... setting the Format of the control won't rescue it. ... the date fields in reports always format ...
    (microsoft.public.access.reports)
  • Re: Price Data Formatting
    ... I'm loading into the application price data that has a format I do not know ... Since price data format is all dependent on the market selected (say IBM ... rounded/truncated to 2 digits following the decimal as well. ... Dim sStr As String ...
    (microsoft.public.vb.general.discussion)
  • Re: Format Problem
    ... I set the numberformat property to General and it still does ... for the long date format. ... for the month and date separator, and displays two digits for the year. ... Currency Displays a number according to the Windows regional ...
    (microsoft.public.excel.programming)
  • Re: real, kind difference between gfortran an ifort
    ... IEEE double format that can be represented exactly. ... Noise is the term that physicists and engineers would usually use. ... (their significance is less than the last bit of the floating point ... have gotten all of the digits printed correctly if a longer format had ...
    (comp.lang.fortran)