HomeНаука и техникаRelated VideosMore From: Caleb Curry

MySQL 32 - FLOAT and DOUBLE Data Types

120 ratings | 7810 views
FLOAT and DOUBLE data types are data types that can be used to store numbers that can include decimal numbers. They are specifically used to store estimates. What do I mean? I mean that the precision of a FLOAT or DOUBLE value can be lost when doing math. The data types are only capable of maintaining a certain level of precision. The level of precision is usually adequate for most mathematical operations. If you need to store exact data, you will want to look into using the INT or DECIMAL data type instead. The numbers stored in a FLOAT or DOUBLE column are called floating point numbers, we'll see why in just a moment. Why are they called floating point numbers? let's look at a number. 150. This number could be represented as 150, or it could be represented as 1.5 * 10^2, or 1.5e2. With floating point numbers, scientific notation is used. These numbers are called floating point numbers because the decimal can float to different spots as we change the exponent. This means that the data type needs to store the number, how many decimal the number needs moved, and a sign bit. The benefit of floating point numbers is that they allow us to store pretty huge numbers. The down side is that they are not storing values exactly because they are limited in size. This means that only a certain level of precision is to be expected from a floating point data type. If you remember from the video of DECIMAL, precision is the number of digits in a number. As long as the precision for one of these data types exceeds the need for your specific data, the data type can work fine. For example, if you are storing a number like 15 trillion, you don't have to worry as much with precision as your number does not contain a lot of digits. This number can be represented as 1.5 x 10^13. This is a lot different than trying to store 1.5534534534 x10^13. Now we know both of these data types do not maintain a high number of digits correctly, but what is the difference between FLOAT and DOUBLE. The difference is the amount of storage they take up. Float takes up 4 bytes while DOUBLE takes up 8. The benefit in DOUBLE is that because it has more room to store data, it has a higher level of precision and can store bigger numbers. Now, what level of precision can you expect from either of these? FLOAT around 7 and DOUBLE around 15. Now, these data types are obnoxious because the exact values depend on your operating system and in general these monsters cannot be trusted. Especially when you start doing math with different numbers. In general, it is recommended to use the DOUBLE data type to have a higher level of precision and calculations in MySQL are done with DOUBLE. Always remember… prepare for trouble, make it double. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support me! http://www.patreon.com/calebcurry Subscribe to my newsletter: http://bit.ly/JoinCCNewsletter Donate!: http://bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: http://CalebCurry.com Facebook: http://www.facebook.com/CalebTheVideoMaker Google+: https://plus.google.com/+CalebTheVideoMaker2 Twitter: http://twitter.com/calebCurry Amazing Web Hosting - http://bit.ly/ccbluehost (The best web hosting for a cheap price!)
Html code for embedding videos on your blog
Text Comments (10)
MrWalkThrough (3 months ago)
Thank you ;)
John Bitzios (6 months ago)
Has the "e" value something to do with the exponential constant "e" or not??
André Gomes (1 year ago)
@CalebTheVideoMaker2 OMG! 15 * 100 is 150 !!?? u joking ? xD
BAD-W D (8 months ago)
André Gomes 1.5 × 100 he said
astetik boi (1 year ago)
So hot
Aaron Webb (1 year ago)
ive never met a programmer in my life thats handwriting didn't look like a 8 year old love the videos !
Jeffrey Townsend (2 years ago)
Wish you were online right now Caleb! Sure could use your help in getting this DB set up and running for a class project. I installed it wrong not knowing I did and been lost since I found out I did...lmao....gggrrrrr! I'm newb in DBM, but gotta know it, not only for school but for the businesses I'm building. You rock Caleb and will be watching these videos over and over again all night and day if need be!
Mohan Pierce (2 years ago)
hey ya a big fan of yours,i need a help ,I need to bring my database online so that it can be remotely accessed from my freinds computer"s mysql connectivity java program using jdbc:which will try to connect using the public ip of which i have to make my database remotely accesed;What i am basically asking is how to make mysql database remotely accesed using public ip so that it can be accesed through the jdbc mysql connectivity program hope you reply soon:) More like:how to make adatabase online so that it can be accesed by an javaprogram frm anywhere using an dynamic public ip or any other way of ur choice
Hazem Fntp (2 years ago)
Thanks but.. I really get bored :( am sorry I want you to apply :\ and start programming
Reem Said (2 years ago)

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.