Full #Javascript #tutorial for #beginners :
http://bizanosa.com/js
Learn HTML, CSS and Javascript :
http://bizanosa.com/sp/learn-html-css...
Javascript Tutorial 2018
32 javascript parsefloat - JavaScript for Beginners.
This is a Javascript tutorial from scratch for any beginner. Use the above link to watch the full JS video tutorial..
Next Video: • 33 JAVASCRIPT Literals - JS Tutoria...
Previous Video: • 31 ParseInt Javascript - Javascript ...
Hey, and welcome back.
In the last part we were looking at parseInt().
Now, we get to move on to parseFloat().
And the good thing about this, it is not that complicated.
You put in a string and it returns a floating point number.
So, this is not as complex as the other one.
You just put in the number, if you just put in the number within there, it will return to you the floating point number.
So what is a floating point number? A floating point number is a number that has, it is either a positive or a negative number.
It has an integer part.
So maybe 200.
So it may be positive or it may be negative.
So it can be 200 or it can be -200.
And then it also has or it may have a decimal point.
So maybe it can be 200.22, that is a floating point number.
Or it can also be a plus, a positive or a negative number that has an exponent.
So 2 exponent of 2 or negative 2.
So maybe we want to represent 3.99 as an exponent.
This would be 3 exponential of -2 or rather 399 exponential -2 to give us that.
So to represent 3.99, it would be as an exponent, it would be 399e-2.
So this is also a floating point number.
So if a string cannot be parsed, it will return ‘not a number’.
So for instance, this is not possible because this will not give us a decimal number.
So in our case with the parseFloat(), all the numbers must be decimal unlike the other one, where we had certain other radices we could use.
Here we only have decimal numbers.
So it's a decimal number.
So this cannot be parsed into a number and this will return 'not a number'.
So if this cannot be parsed, it will return 'not a number' and then it will return up to the possible point where it can actually get a real number.
So for example, in this case it's going to return this up to this point.
It will return it up to this point and it will ignore, it will ignore all these other parts.
So it will return it up to there because at least this makes sense to this function.
So let's see an example with this, all of this in one long example.
And then, we can end the video.
So if I come back to Scratchpad, if I come back to Scratchpad, I will delete all this.
So this one is now parseFloat().
Now parseFloat(), we don’t need the radix.
So parseFloat(), this one, display.
It will give us that.
If it is 9 and then maybe exponential of 3.
Then we display.
It will give us that.
Then maybe it is 9.33e3.
Display.
It will give us that.
Maybe it is just 9.33, it will return back that.
Let me remove this and then maybe it is 123e-21 and then with the space if we display, it will return this.
So if we reduce this maybe to ‘e-4’ and we display that, at least it gives us something that is like that.
So it returns it up to the point that it can.
So if I say 45e-3 and then exponential again of 32, 34, it will return it up to the point that it can.
So if I do this, it will return it up to that point only.
So it's going to be 0.045.
So if I display this one, zero, oh come on.
So if I come here, and I display that one it will give us 0.045 and if I add a space in there, it will only give us up to the point that it can.
It cannot parse a space.
And therefore if I display the results of that, it only brings back 45.
And if I make it something that is not understood like this, this can be, maybe this is a hexadecimal number and you try to put it here to convert it into a floating point number using the parseFloat() function.
This will give us ‘not a number’ because this number is not a decimal number.
So if I display that one, it will give us ‘not a number’.
And if I start with a space, let me say I start with a space.
2 space 4, I start with a space.
And then, I try, let me first of all remove all these other results.
Then I try to display that, it will ignore the first space and give us a number.
But, it will not ignore the next space.
The next ones are not ignored.
So bear that in mind.
So it ignores even symbols.
If I come here and I say ‘2+4*4’ and I come here and I try to display this one, it will ignore all these others because they’re not numbers.
It just brings back up to the point that it can.
So that’s it for this video.
In this video we have seen how the parseFloat() works.
And this one is much easier to use because we just put in the number in there.
GET SOCIAL WITH ME:
FACEBOOK: / rwahowa
INSTAGRAM: / rwahowa
TWITTER: / rwahowa
VIMEO: https://vimeo.com/bizanosa/
WEBSITE : http://rwahowa.com
Смотрите видео 32 Javascript parsefloat - Javascript Tutorial 2018 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ricky Wahowa (rwahowa) 19 Июль 2017, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 41 раз и оно понравилось людям.