long float

Discussion in 'C Programming' started by Lew Pitcher, Mar 12, 2014.

  1. Lew Pitcher

    Lew Pitcher Guest

    In K&R C ("The C Programming Language", Appendix A, section 8.2 "Type
    Specifiers"), the authors enumerate the uses of the "long" type specifier
    thusly:
    The words long, short, and unsigned may be thought of as adjectives; the
    following combinations are acceptable.
    short int
    long int
    unsigned int
    long float
    The meaning of the last is the same as double.

    Does "long float" still mean "double" in ISO Standard C (any vintage)?

    FWIW, both GCC v4.2.4 and v4.7.1 complain with the same sort of error when
    presented with a long float:
    error: both 'long' and 'float' in declaration specifiers


    ~/Code/clc $ cat lf.c
    #include <stdio.h>
    #include <stdlib.h>
    int main(void)
    {
    long float should_be_double;

    should_be_double = 1.0;

    return EXIT_SUCCESS;
    }

    ~/Code/clc $ gcc -o lf lf.c
    lf.c: In function 'main':
    lf.c:5:8: error: both 'long' and 'float' in declaration specifiers
     
    Lew Pitcher, Mar 12, 2014
    #1
    1. Advertisements

  2. Lew Pitcher

    Kaz Kylheku Guest

    It kinda lives on in scanf's conversion specifier:

    scanf("%lf", &double_var);
     
    Kaz Kylheku, Mar 12, 2014
    #2
    1. Advertisements

  3. Lew Pitcher

    James Kuyper Guest

    No, as far as C99 and C2011 are concerned. I don't have a copy of C90
    that I can check.
     
    James Kuyper, Mar 12, 2014
    #3
  4. No, "long float" is a constraint violation in C89/C90, C99, and C11.
     
    Keith Thompson, Mar 12, 2014
    #4
  5. Lew Pitcher

    jacob navia Guest

    Le 12/03/2014 05:19, Lew Pitcher a écrit :
    No, but soon, I will implement in the lcc-win system "short float", to
    describe 16 bit floating point numbers introduced some years ago, and
    used widely in GPUs.
     
    jacob navia, Mar 12, 2014
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.