Re: integer and floating-point bit pattern
From: Mantorok Redgormor (nethlek_at_tokyo.com)
Date: 10/02/03
- Next message: Keith Thompson: "Re: Attn. C gurus"
- Previous message: Richard Heathfield: "Re: [OT, spam] Backup your projects neatly"
- In reply to: Jack Klein: "Re: integer and floating-point bit pattern"
- Next in thread: Mike Wahler: "Re: integer and floating-point bit pattern"
- Reply: Mike Wahler: "Re: integer and floating-point bit pattern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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?
- Next message: Keith Thompson: "Re: Attn. C gurus"
- Previous message: Richard Heathfield: "Re: [OT, spam] Backup your projects neatly"
- In reply to: Jack Klein: "Re: integer and floating-point bit pattern"
- Next in thread: Mike Wahler: "Re: integer and floating-point bit pattern"
- Reply: Mike Wahler: "Re: integer and floating-point bit pattern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|