C Programming Tutorial 22 - Scientific Notation with Floating Point Numbers

submitted by mkenny400 on 03/19/18 1

Now that you've seen the basics, it's important for you to understand how floating point numbers are actually stored. Floating point numbers are stored in scientific notation.   If you need a refresher on scientific notation, that's fine. Essentially, we can represent a number as multiplied by 10 to some power. So 24000 becomes 2.4 X 10^4 = 24,000.   We can also have 10 to a negative power. So .000045 becomes 4.5 X 10^-5. The number that is being multiplied actually has a fancy name. It's called the mantissa. They call the other part the exponent, but always remember it's times 10 raised to that exponent, not just the number itself. 2.4 to the fourth power is much different than 2.4 x 10 to the fourth power.   Sometimes it is actually easier to input our data in the form of scientific notation. The way we do that is to use an e. This basically means "times 10 to the power of" and then use a number either positive or negative. Let's try converting our number to scientific notation for the input and make sure we get exactly the same output.   int dogs = 2.5e4; // same as dogs = 25000   This is a great time for me to introduce a new keyword to you…hardcoding. Hardcoding is when we type in a value in the code directly rather than getting the value from the input, a database or something like that. Sometimes hardcoding is okay, but in this situation we don't want to hardcode the value of these variables. As we have it, this program can take a couple specific values and output them. But imagine if we took any input in the form of scientific notation and it converted it to decimal notation. Then our program would be legit sauce. That's what we are going to be talking about in the next video. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support me! www.patreon.com/calebcurry Subscribe to my newsletter: eepurl.com/-8qtH Donate!: bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: CalebCurry.com Facebook: www.facebook.com/CalebTheVideoMaker Google+: plus.google.com/+CalebTheVideoMaker2 Twitter: twitter.com/calebCurry Amazing Web Hosting - www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Leave a comment

Be the first to comment

Collections with this video
Email
Message
×
Embed video on a website or blog
Width
px
Height
px
×
Join Huzzaz
Start collecting all your favorite videos
×
Log in
Join Huzzaz

facebook login
×
Retrieve username and password
Name
Enter your email address to retrieve your username and password
(Check your spam folder if you don't find it in your inbox)

×