Partage
  • Partager sur Facebook
  • Partager sur Twitter

float??

Qu'est ce donc?

    21 novembre 2007 à 19:21:34

    Bonjour, j'aurai une question toue bête..
    Qu'est ce qu'un float? J'ai vu ça ici par exemple:
    1. void affiche_balle(float x, float y, float taille)
    • Partager sur Facebook
    • Partager sur Twitter
    Anonyme
      21 novembre 2007 à 19:30:26

      float est un type de variable, comme int, short ou double. Ce qui caractérise le float, c'est qu'il permet de stocker un nombre à virgule et qu'il est écrit sur 4 octets.

      Assure-toi de lire un minimum avant de poser des questions de ce genre, le float est présenté dans le tutoriel de m@teo21. (voir ici) Un simple recherche google t'aurais donné ta réponse.
      • Partager sur Facebook
      • Partager sur Twitter
        21 novembre 2007 à 19:40:38

        Les questions toutes bête ont souvent des réponses toutes bêtes, comme le dit PY float est un type de variables permettant de stocker des nombres à virgules.
        Double est aussi un type de variables équivalant sauf que double, comme son nom l'indique affiche un nombre à virgule en double précision (codé en 8 octets au lieu de 4 pour float)

        Un bon programmeur doit savoir jongler en ces deux types en fonction des besoins et des taches à effectuées.

        Je te conseil vivement de revoir les fondements du C (si tu code en C bien sur) car les variables et la mémoire sont important dans la programmation, pour afficher la longueur d'un segment on utilisera float alors que pour un le calcul d'un rapport trigonométrique tel que le cosinus d'un angle on aura tendance à l'afficher en double pour une grand précision.
        Après c'est à toi de voir.

        A plus tard.

        Cordialement WY.
        • Partager sur Facebook
        • Partager sur Twitter
          21 novembre 2007 à 19:54:05

          c'est un type de variable , nombre décimeau
          • Partager sur Facebook
          • Partager sur Twitter
            21 novembre 2007 à 21:00:56

            Citation : PY

            float est un type de variable, comme int, short ou double. Ce qui caractérise le float, c'est qu'il permet de stocker un nombre à virgule et qu'il est écrit sur 4 octets.


            Citation : War - Yor

            (codé en 8 octets au lieu de 4 pour float)


            Euh non, pas forcément. Ca dépend de l'implémentation.

            D'après la norme, un float est <= à un double... Les valeurs de l'implémentation sont données par <float.h>.

            Citation : N1124


            The types
            float_t
            double_t
            are floating types at least as wide as float and double, respectively, and such that
            double_t is at least as wide as float_t. If FLT_EVAL_METHOD equals 0,
            float_t and double_t are float and double, respectively; if
            FLT_EVAL_METHOD equals 1, they are both double; if FLT_EVAL_METHOD equals
            2, they are both long double; and for other values of FLT_EVAL_METHOD, they are
            otherwise implementation-defined.193)



            La norme donne des minima :
            (C'est assez technique...)

            Citation : N1124


            5.2.4.2.2 Characteristics of floating types <float.h>
            1 The characteristics of floating types are defined in terms of a model that describes a
            representation of floating-point numbers and values that provide information about an
            implementation’s floating-point arithmetic.16) The following parameters are used to
            define the model for each floating-point type:
            s sign (±1)
            b base or radix of exponent representation (an integer > 1)
            e exponent (an integer between a minimum emin and a maximum emax)
            p precision (the number of base-b digits in the significand)
            fk nonnegative integers less than b (the significand digits)
            2 Afloating-point number (x) is defined by the following model:
            x = sbe
            p
            k=1 Σ fkb−k , emin ≤ e ≤ emax
            3 In addition to normalized floating-point numbers ( f1 > 0 if x ≠ 0), floating types may be
            able to contain other kinds of floating-point numbers, such as subnormal floating-point
            numbers (x ≠ 0, e = emin, f1 = 0) and unnormalized floating-point numbers (x ≠ 0,
            e > emin, f1 = 0), and values that are not floating-point numbers, such as infinities and
            NaNs. A NaN is an encoding signifying Not-a-Number. A quiet NaN propagates
            through almost every arithmetic operation without raising a floating-point exception; a
            signaling NaN generally raises a floating-point exception when occurring as an
            arithmetic operand.17)
            4 An implementation may give zero and non-numeric values (such as infinities and NaNs) a
            sign or may leave them unsigned. Wherever such values are unsigned, any requirement
            in this International Standard to retrieve the sign shall produce an unspecified sign, and
            any requirement to set the sign shall be ignored.
            15) See 6.2.5.
            16) The floating-point model is intended to clarify the description of each floating-point characteristic and
            does not require the floating-point arithmetic of the implementation to be identical.
            17) IEC 60559:1989 specifies quiet and signaling NaNs. For implementations that do not support
            IEC 60559:1989, the terms quiet NaN and signaling NaN are intended to apply to encodings with
            similar behavior.
            §5.2.4.2.2 Environment 23
            ISO/IEC 9899:TC2 Committee Draft — May 6, 2005 WG14/N1124
            5 The accuracy of the floating-point operations (+, -, *, /) and of the library functions in
            <math.h> and <complex.h> that return floating-point results is implementationdefined,
            as is the accuracy of the conversion between floating-point internal
            representations and string representations performed by the library functions in
            <stdio.h>, <stdlib.h>, and <wchar.h>. The implementation may state that the
            accuracy is unknown.
            6 All integer values in the <float.h> header, except FLT_ROUNDS, shall be constant
            expressions suitable for use in #if preprocessing directives; all floating values shall be
            constant expressions. All except DECIMAL_DIG, FLT_EVAL_METHOD, FLT_RADIX,
            and FLT_ROUNDS have separate names for all three floating-point types. The floatingpoint
            model representation is provided for all values except FLT_EVAL_METHOD and
            FLT_ROUNDS.
            7 The rounding mode for floating-point addition is characterized by the implementationdefined
            value of FLT_ROUNDS:18)
            -1 indeterminable
            0 toward zero
            1 to nearest
            2 toward positive infinity
            3 toward negative infinity
            All other values for FLT_ROUNDS characterize implementation-defined rounding
            behavior.
            8 The values of operations with floating operands and values subject to the usual arithmetic
            conversions and of floating constants are evaluated to a format whose range and precision
            may be greater than required by the type. The use of evaluation formats is characterized
            by the implementation-defined value of FLT_EVAL_METHOD:19)
            -1 indeterminable;
            0 evaluate all operations and constants just to the range and precision of the
            type;
            18) Evaluation of FLT_ROUNDS correctly reflects any execution-time change of rounding mode through
            the function fesetround in <fenv.h>.
            19) The evaluation method determines evaluation formats of expressions involving all floating types, not
            just real types. For example, if FLT_EVAL_METHOD is 1, then the product of two float
            _Complex operands is represented in the double _Complex format, and its parts are evaluated to
            double.
            24 Environment §5.2.4.2.2
            WG14/N1124 Committee Draft — May 6, 2005 ISO/IEC 9899:TC2
            1 evaluate operations and constants of type float and double to the
            range and precision of the double type, evaluate long double
            operations and constants to the range and precision of the long double
            type;
            2 evaluate all operations and constants to the range and precision of the
            long double type.
            All other negative values for FLT_EVAL_METHOD characterize implementation-defined
            behavior.
            9 The values given in the following list shall be replaced by constant expressions with
            implementation-defined values that are greater or equal in magnitude (absolute value) to
            those shown, with the same sign:
            — radix of exponent representation, b
            FLT_RADIX 2
            — number of base-FLT_RADIX digits in the floating-point significand, p
            FLT_MANT_DIG
            DBL_MANT_DIG
            LDBL_MANT_DIG
            — number of decimal digits, n, such that any floating-point number in the widest
            supported floating type with pmax radix b digits can be rounded to a floating-point
            number with n decimal digits and back again without change to the value,
            ⎧⎨⎩
            pmax log10 b
            ⎡1 + pmax log10 b⎤
            if b is a power of 10
            otherwise
            DECIMAL_DIG 10
            — number of decimal digits, q, such that any floating-point number with q decimal digits
            can be rounded into a floating-point number with p radix b digits and back again
            without change to the q decimal digits,
            ⎧⎨⎩
            p log10 b
            ⎣(p − 1) log10 b⎦
            if b is a power of 10
            otherwise
            FLT_DIG 6
            DBL_DIG 10
            LDBL_DIG 10
            §5.2.4.2.2 Environment 25
            ISO/IEC 9899:TC2 Committee Draft — May 6, 2005 WG14/N1124
            — minimum negative integer such that FLT_RADIX raised to one less than that power is
            a normalized floating-point number, emin
            FLT_MIN_EXP
            DBL_MIN_EXP
            LDBL_MIN_EXP
            — minimum negative integer such that 10 raised to that power is in the range of
            normalized floating-point numbers,⎡⎢
            log10 bemin−1⎤⎥
            FLT_MIN_10_EXP -37
            DBL_MIN_10_EXP -37
            LDBL_MIN_10_EXP -37
            — maximum integer such that FLT_RADIX raised to one less than that power is a
            representable finite floating-point number, emax
            FLT_MAX_EXP
            DBL_MAX_EXP
            LDBL_MAX_EXP
            — maximum integer such that 10 raised to that power is in the range of representable
            finite floating-point numbers, ⎣log10((1 − b−p)bemax )⎦
            FLT_MAX_10_EXP +37
            DBL_MAX_10_EXP +37
            LDBL_MAX_10_EXP +37
            10 The values given in the following list shall be replaced by constant expressions with
            implementation-defined values that are greater than or equal to those shown:
            — maximum representable finite floating-point number, (1 − b−p)bemax
            FLT_MAX 1E+37
            DBL_MAX 1E+37
            LDBL_MAX 1E+37
            11 The values given in the following list shall be replaced by constant expressions with
            implementation-defined (positive) values that are less than or equal to those shown:
            — the difference between 1 and the least value greater than 1 that is representable in the
            given floating point type, b1−p
            FLT_EPSILON 1E-5
            DBL_EPSILON 1E-9
            LDBL_EPSILON 1E-9
            26 Environment §5.2.4.2.2
            WG14/N1124 Committee Draft — May 6, 2005 ISO/IEC 9899:TC2
            — minimum normalized positive floating-point number, bemin−1
            FLT_MIN 1E-37
            DBL_MIN 1E-37
            LDBL_MIN 1E-37
            Recommended practice
            12 Conversion from (at least) double to decimal with DECIMAL_DIG digits and back
            should be the identity function.
            13 EXAMPLE 1 The following describes an artificial floating-point representation that meets the minimum
            requirements of this International Standard, and the appropriate values in a <float.h> header for type
            float:
            x = s16e
            6
            k=1 Σ fk16−k , −31 ≤ e ≤ +32
            FLT_RADIX 16
            FLT_MANT_DIG 6
            FLT_EPSILON 9.53674316E-07F
            FLT_DIG 6
            FLT_MIN_EXP -31
            FLT_MIN 2.93873588E-39F
            FLT_MIN_10_EXP -38
            FLT_MAX_EXP +32
            FLT_MAX 3.40282347E+38F
            FLT_MAX_10_EXP +38
            14 EXAMPLE 2 The following describes floating-point representations that also meet the requirements for
            single-precision and double-precision normalized numbers in IEC 60559,20) and the appropriate values in a
            <float.h> header for types float and double:
            x f = s2e
            24
            k=1 Σ fk2−k , −125 ≤ e ≤ +128
            xd = s2e
            53
            k=1 Σ fk2−k , −1021 ≤ e ≤ +1024
            FLT_RADIX 2
            DECIMAL_DIG 17
            FLT_MANT_DIG 24
            FLT_EPSILON 1.19209290E-07F // decimal constant
            FLT_EPSILON 0X1P-23F // hex constant
            FLT_DIG 6
            FLT_MIN_EXP -125
            FLT_MIN 1.17549435E-38F // decimal constant
            FLT_MIN 0X1P-126F // hex constant
            20) The floating-point model in that standard sums powers of b from zero, so the values of the exponent
            limits are one less than shown here.
            §5.2.4.2.2 Environment 27
            ISO/IEC 9899:TC2 Committee Draft — May 6, 2005 WG14/N1124
            FLT_MIN_10_EXP -37
            FLT_MAX_EXP +128
            FLT_MAX 3.40282347E+38F // decimal constant
            FLT_MAX 0X1.fffffeP127F // hex constant
            FLT_MAX_10_EXP +38
            DBL_MANT_DIG 53
            DBL_EPSILON 2.2204460492503131E-16 // decimal constant
            DBL_EPSILON 0X1P-52 // hex constant
            DBL_DIG 15
            DBL_MIN_EXP -1021
            DBL_MIN 2.2250738585072014E-308 // decimal constant
            DBL_MIN 0X1P-1022 // hex constant
            DBL_MIN_10_EXP -307
            DBL_MAX_EXP +1024
            DBL_MAX 1.7976931348623157E+308 // decimal constant
            DBL_MAX 0X1.fffffffffffffP1023 // hex constant
            DBL_MAX_10_EXP +308
            If a type wider than double were supported, then DECIMAL_DIG would be greater than 17. For
            example, if the widest type were to use the minimal-width IEC 60559 double-extended format (64 bits of
            precision), then DECIMAL_DIG would be 21.



            • Partager sur Facebook
            • Partager sur Twitter
            Music only !

            float??

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown