Re: integer and floating-point bit pattern

From: Mantorok Redgormor (nethlek_at_tokyo.com)
Date: 10/02/03


Date: 2 Oct 2003 13:53:00 -0700

Jack Klein <jackklein@spamcop.net> wrote in message news:<ds6nnvogj8i7410tav8e0c5fucq10rf07k@4ax.com>...
> On 1 Oct 2003 13:56:10 -0700, nethlek@tokyo.com (Mantorok Redgormor)
> wrote in comp.lang.c:
>
> > Would the following determine if the bit pattern for
> > floating point 0.0 and integer 0 are the same?
> >
> > #include <stdio.h>
> > int main(void)
> > <%
> > if(0 == 0.0f)
> > puts("Bit pattern is the same.");
> >
> > return 0;
> > %>
> >
> >
> > Also is it undefined behavior for failure
> > to include the proper header file for any
> > function or just functions that accept a
> > variable number of arguments?
>
> Mike already answered your first question, he was a little unsure
> about the second.
>
> It is not and has never been a requirement in C that you include
> header files, except in a few cases where data types with
> implementation-defined types and members (such as time_t, FILE, etc.).
>
> Prior to the current (1999) standard you did not need a prototype or a
> declaration to call a function that returned int and accepted a fixed
> number and type of arguments, if all the argument types were those
> provided by default promotions.
>
> Under the current standard, there must be at least a declaration in
> scope for any function you call, specifying the return type. Implicit
> int is illegal, including the return type of functions. The
> declaration does not need to be a prototype if the function accepts a
> fixed number and type of arguments if the types are the default
> promotions.
>
> Since the very first 1989 ANSI standard, it produces undefined
> behavior to call a variadic function without a full prototype in
> scope.
>
> It is perfectly valid under all versions of the C standard to provide
> your own prototype for a standard function so long as you get it
> correct.
>
> If you write a prototype equivalent to:
>
> char *strchr(const char *s, int c);
>
> ...then you can call this function without including <string.h>.

Thanks for the response.

I'm puzzled about one thing though. Why is unsigned char *
the preferred type for handling underlying representations
of types?



Relevant Pages

  • Re: integer and floating-point bit pattern
    ... > to include the proper header file for any ... Prior to the current standard you did not need a prototype or a ... declaration to call a function that returned int and accepted a fixed ...
    (comp.lang.c)
  • Re: General question
    ... declaration for, it assumed that it was a function returning an int ... The first true C standard, ANSI/ISO of 1989 and 1990, changed things. ... Its prototype is: ...
    (comp.lang.c)
  • Re: constant string doubt
    ... The standard library functions are part of the program. ... The actions constitute undefined behavior. ... Constraint violations require a diagnostic, ... int main{ ...
    (comp.lang.c)
  • Re: whats wrong with atof() and casting?
    ... The return type of the function was int, ... Since atofDOES NOT return an int, this is wrong and undefined behavior. ... Note that a compiler is not required to do anything at all when you ... There is no requirement in the C standard that they do. ...
    (comp.lang.c)
  • Re: How can I do sort program for unsorted setup file?
    ... we have had a standard for C ... main has return type int. ... exit() is prototyped/declared in. ... There was no prototype for customer_input, ...
    (comp.lang.c)