Jump to content


Photo

Mysql Type For Integers With Decimals


  • Please log in to reply
6 replies to this topic

#1 1internet

1internet

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 19 November 2012 - 10:12 PM

I am trying to store integers that contain decimals. When I select the type INT, it will not allow me to use decimals. What type do I need?
It's just for numbers like 2.4, or 6.3, one decimal place is fine.

#2 Pikachu2000

Pikachu2000

    I hate everything.

  • Staff Alumni
  • 11,378 posts
  • LocationFuture Independent Republic of Texas
  • Age:106

Posted 19 November 2012 - 10:27 PM

Integers, by definition, are not decimal. They are whole numbers. 
"Java" is to "Javascript" about the same as "fun" is to "funeral".

Why $_SERVER['PHP_SELF'] is bad. || Why ORDER BY RAND() is bad || Every problem can be solved with rm -rf *

Random Quote: "

#3 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,576 posts
  • LocationBonita, FL

Posted 19 November 2012 - 10:47 PM

11.2. Numeric Types


Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#4 1internet

1internet

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 20 November 2012 - 04:45 AM

So which one do I need to represent e.g. 5.4?

#5 Muddy_Funster

Muddy_Funster

    Advanced Member

  • Members
  • PipPipPip
  • 2,993 posts

Posted 20 November 2012 - 04:59 AM

Either float or decimal set with 1 decimal place
A simple password hash :

function makePass($word=''){
  $dbSalt = '$2a$07$'.substr(hash('whirlpool',$word),0,22);
  $dbPass = crypt($word, $dbSalt);
 return substr($dbPass,12);
}



My SQL/PHP Blog

#6 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 20 November 2012 - 05:01 AM

Follow kicken's link, and read: You'll find out.
Keeping it simple.

#7 fenway

fenway

    MySQL Si-Fu / PHP Resident Alien

  • Moderators
  • 16,185 posts
  • LocationToronto, ON

Posted 20 November 2012 - 10:47 PM

Don't use approximate data types with an exact one will do.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com