Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    [mysql] variabile di tipo float

    Ciao, devo impostare una variabile con float in modo che il massimo valore impostabile sia 99,99

    non capisco perché non accetta float (2,2).. cioé mi imposta (3,2) oppure (2,1)

    inoltre dai vari help che si trovano in giro ed anche sul manuale, mi sembra che ci sia quacosa che non torna

    Cioé se io imposto float (3,2) NON è vero che limito a 3 la parte intera e 2 quella decimale, infatti il massimo numero intero inseribile è di 5 cifre (3+2) mentre quello decimale è solo di 2

    ??
    [°_°] The Web Styler Project [°_°]
    :.:Classifica Spettacolare :.:
    :-:Partecipa :-: GUADAGNA SCRIVENDO ARTICOLI !! fino a 2,5 crediti per parola

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    per inserire numeri nel formato XX,XX devi dare FLOAT(4,2).
    4 digit totali, di cui 2 dopo la virgola...

    "When the keyword FLOAT is used for a column type without a precision specification, MySQL uses four bytes to store the values. MySQL also supports variant syntax with two numbers given in parentheses following the FLOAT keyword. The first number represents the display width and the second number specifies the number of digits to be stored and displayed following the decimal point (as with DECIMAL and NUMERIC). When MySQL is asked to store a number for such a column with more decimal digits following the decimal point than specified for the column, the value is rounded to eliminate the extra digits when the value is stored."
    http://dev.mysql.com/doc/mysql/en/Numeric_types.html
    think simple think ringo

  3. #3
    Originariamente inviato da marketto
    per inserire numeri nel formato XX,XX devi dare FLOAT(4,2).
    4 digit totali, di cui 2 dopo la virgola...

    "When the keyword FLOAT is used for a column type without a precision specification, MySQL uses four bytes to store the values. MySQL also supports variant syntax with two numbers given in parentheses following the FLOAT keyword. The first number represents the display width and the second number specifies the number of digits to be stored and displayed following the decimal point (as with DECIMAL and NUMERIC). When MySQL is asked to store a number for such a column with more decimal digits following the decimal point than specified for the column, the value is rounded to eliminate the extra digits when the value is stored."
    http://dev.mysql.com/doc/mysql/en/Numeric_types.html
    no, purtroppo non è così

    imposta float (4,2)
    e potrai inserire anche 9999,99

    6 in totale di cui "teoricamente" 4 integer e 2 decimali

    purtroppo si piò anche inserire 666666

    bo
    [°_°] The Web Styler Project [°_°]
    :.:Classifica Spettacolare :.:
    :-:Partecipa :-: GUADAGNA SCRIVENDO ARTICOLI !! fino a 2,5 crediti per parola

  4. #4
    [°_°] The Web Styler Project [°_°]
    :.:Classifica Spettacolare :.:
    :-:Partecipa :-: GUADAGNA SCRIVENDO ARTICOLI !! fino a 2,5 crediti per parola

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.