max size for printf() format conversion?

R

Richard Bos

Keith Thompson said:
I suppose it's undefined behavior in the sense that the standard
doesn't guarantee that it will work. On the other hand, an
implementation could choose to guarantee a larger number of
characters, or it could state that there are no fixed limits, only
those imposed by resource constraints.

So they could, but that doesn't make it any less undefined by the
Standard. An implementation can choose to define, for itself only, _any_
case of undefined behaviour. If an implementation wants to define that
passing a null pointer to strlen() returns 0, that's fine. Doesn't make
passing null pointers to strlen() any more defined, though - except for
that implementation. The same is true in this case.

Richard
 
P

pete

Keith Thompson wrote:
I suppose it's undefined behavior in the sense that the standard
doesn't guarantee that it will work.

That's as undefined as code can get.

N869
3. Terms and definitions
3.18
[#1] undefined behavior
behavior, upon use of a nonportable or erroneous program
construct, of erroneous data, or of indeterminately valued
objects, for which this International Standard imposes no
requirements
 
G

glen herrmannsfeldt

Keith Thompson wrote:
(snip)
Actually, the largest floating-point ranges I've seen are on systems
with 128-bit IEEE floating-point, including ordinary x86 systems.
It's basically the size of the exponent that determines how big a
string the "%f" conversion can generate; such systems typically have
32, 64, and 128 bit floating-point types with 8, 11, and 15 bit
exponents.

I don't know that many supply a printf conversion for the 80 bit
format, though.
Many of the more recent Cray systems use IEEE floating-point. On the
vector systems that use Cray floating point, they seem to support
64-bit and 128-bit formats, both with 13-bit exponents; the 128-bit
format therefore supports a narrower range (but slightly more
precision) than the 128-bit IEEE format.

The CRAY-1 has a 15 bit biased exponent, but it can only have
values between octal 20000 and 57777, or, so they say, approximately
1e-2500 to 1e+2500. One could, then, expect up to 2500 digits from
a %f format item.

-- glen
 
D

Dik T. Winter

> Keith Thompson wrote: ....
>
> The CRAY-1 has a 15 bit biased exponent, but it can only have
> values between octal 20000 and 57777, or, so they say, approximately
> 1e-2500 to 1e+2500. One could, then, expect up to 2500 digits from
> a %f format item.

The Cyber 205 had a 16 bits 2-s complement exponen, providing nearly
the whole range. 0x8000 (which should be the minimum exponent) indicated
that the number was 0.0. (An example of a machine where all 0 bits in
a floating point number did not give you 0.0. If I remember well, the
floating point format was similar to that used in some Milspec processor.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top