我如何在javascript中理解和解决这些数学和数字示例? [英] How do I understand and solve these maths and numbers examples in javascript?

查看:69
本文介绍了我如何在javascript中理解和解决这些数学和数字示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在关注JavaScript的w3schools教程,并且我真的被卡在数字/数字方法和数学页面上。



我真的不明白数学的总和,或者如何或为什么答案会出现在这些长而复杂的数字中。也许我错过了显而易见的事情,你很容易找到答案,显而易见,或简单的数学,或者说这是这就是JavaScript可以做的事情,但你本人并不打算做到这一点。 ... 我不知道。



我无法做到的是:



- 十六进制数字,答案128 ,80和1000000你怎么做到的?



- toExponential方法。 (返回9.66e + 0?代码怎么做?)



- tofixed()方法 - (我只是不明白必须有一些模式或乘法或其他东西,但我只是没有得到它。)



- toPresision方法......不知道。 (我知道我现在听起来很蠢。)



和Number()方法 - 看起来像是合乎逻辑的,应该很容易但又一次我不知道该怎么做做.. :(



- parselent方法... 10 = 10,是的,但是10.33 = 10?10 20 30 = 10?对不起,什么..?



(这与parseFloat()方法相同。)



所以,是的,它看起来很多,但我确信有一些方法可以解释一些会让很多其他东西突然变得有意义的东西。如果你需要查看完整的例子和代码,请访问www.w3schools, JavaScript。第一个问题是关于主题JS Numbers,所有其他问题都在JS Number Methods页面上。



非常感谢任何人能够帮助我!!我很感激,请尽力!



来自我。



我尝试了什么:



几个小时看着所有东西并且没有得到很好的身份证ea,yahoo回答,问我的家人的想法......没什么。 :(

解决方案

数字128在我们的自然基础上:基数10.

这基本上意味着它确实是:

 1 * 10 ^ 2 + 2 * 10 ^ 1 + 8 * 10 ^ 0 



或者

 1 * 100 + 2 * 10 + 8 * 1 

因为这就是基数10的含义 - 你有十个不同的数字(0到9)你得到更大的数字你乘以基数值。



但这不是处理数字的唯一方法。你可以使用任何正整数一个基数,除了0和1(实际上不是真的,你可以使用非整数基数或负基数,但这远远超出了一个小文本框的范围,所以我很想完全忽略它们。)

基本上,所有西方数学都是位置 - 你所说的数字右边的位数就是你为了获得完整而提高基数的力量数字的价值。困惑?好吧 - 让我们再试一次。

我们有一个数字:234

我们可以把它想象为200 + 30 + 4因为2右边有2位数所以要乘以它基数为10,所以2 gest乘以10 ^ 2,或10 * 10,或100.同样,3右边有一位数,所以它乘以10 ^ 1,或10 。4为零,所以它乘以10 ^ 0,或1.

现在好吗?

我们不必使用十作为基数 - 如果我们有两个拇指而不是一个,我们可能会使用12个!但是,对于计算机来说,十二点并不是很有帮助 - 正如你所知 - 只有零和一的东西。这实际上是基数2,我们称之为二进制,它与十号基本完全相同,但可用的数字更少,而且数字更长!例如,以二进制表示234将为11101010 - 使用上述系统自行尝试:

 1 * 2 ^ 7 == 1 * 128 == 128 
1 * 2 ^ 6 == 1 * 64 == 64
1 * 2 ^ 5 == 1 * 32 == 32
0 * 2 ^ 4 == 0 * 16 == 0
1 * 2 ^ 3 == 1 * 8 == 8
0 * 2 ^ 2 == 0 * 4 == 0
1 * 2 ^ 1 == 1 * 2 == 2
0 * 2 ^ 0 == 0 * 1 == 0
---
234
---



计算机说话中的常见基础是16位或十六进制,因为它很容易为计算机工作二进制,也比二进制要短很多!

对于hex ,我们需要十六个数字:0到9,再加上六个,我们使用字母表:A,B,C,D,E和F.

所以在Hex中234是EA :

 E == 14基数十* 16 ^ 1 == 14 * 16 == 224 
A == 10基数十* 16 ^ 0 == 10 * 1 == 10
---
234
---



所以......十六进制中的128是80:

 8 * 16 ^ 1 == 8 * 16 == 128 
0 * 16 ^ 0 == 0 * 1 == 0
---
128
---



您可以使用相同的原则为自己完成剩下的工作! :笑:


I am currently following the w3schools tutorial on JavaScript and am getting REALLY stuck on the Numbers/Number Methods and Maths pages.

I really do not understand the maths to do the sums or how or why the answers come up as these long and complected numbers. Perhaps I am missing the obvious and you find the answer easily, its obvious, or its simple maths, or maybe it is something which is saying "this is what JavaScript can do", but you personally are not meant to be able to do it... I don't know.

The ones I have not been able to do are:

- Hexadecimal numbers , the answers 128, 80 and 1000000 how do you get that?

- The toExponential Method. (returns 9.66e+0? How did the code do that?)

- The tofixed() Method - (I just don't understand there must be some pattern or multiplying or something but i'm just not getting it.)

- toPresision Method... no idea. (I know I am sounding stupid now.)

and the Number() Method - Looks like it is logical and should be easy but again I have no idea what to do.. :(

- The parselent method... 10 = 10, yes, but 10.33 = 10? 10 20 30 = 10? I'm sorry, what..?

(It is the same problem believe as with the parseFloat() Method.)

So, yes, it seems like a lot but I am sure there are ways of explaining some things which will make lots of the others suddenly make sense. If you need to see the full example and code the go to www.w3schools, JavaScript. The very first problem is on the subject "JS Numbers" and all the others are on the page "JS Number Methods".

A big thank you to anybody is able to help me!! I appreciate it, please do your best!

From me.

What I have tried:

Looking at everything for hours and getting no great idea, yahoo answers, asking my family for ideas... nothing. :(

解决方案

The number 128 is in our "natural" base: base 10.
Which basically means that it is really:

1 * 10^2 + 2 * 10^1 + 8 *10^0


Or

1 * 100 + 2 * 10 + 8 * 1

Because that is what "base 10" means - you have ten distinct digits (0 to 9) and you get "bigger numbers" you multiply by the base value.

But that's not the only way to work with numbers. You can use any positive integer as a base, except 0 and 1 (that's not actually true, you can use non-integral bases or negative bases but that gets well beyond the scope of a little text box so I'm goign to ignore those completely).
Basically, all western math is positional - the number of digits to the right of the digit you are talking about is the power to which you raise the base in order to to get the "complete" value for a digit. Confused? OK - lets try again.
We have a number: 234
we can think of it as 200 + 30 + 4 because "2" has 2 digits to its right so be multiply it by the base to the power 2. The base is ten, so 2 gest multiplied by 10^2, or 10 * 10, or 100. Similarly, the "3" has one digit to it's right, so it's multiplied by 10^1, or 10. "4" has zero, so it's multiplied by 10^0, or 1.
OK now?
We don't have to use ten as the base - if we had two thumbs instead of one, we'd probably use 12! But twelve isn;t a lot of help to computers which - as you know - only ever thing in zeros and ones. Which is actually base two, which we call "binary" and it works exactly the same as base ten, but with less digits available, and much, much longer numbers! For example, to represent "234" in binary would be "11101010" - try it for yourself using the system above:

1 * 2^7 == 1 * 128 == 128
1 * 2^6 == 1 *  64 ==  64
1 * 2^5 == 1 *  32 ==  32
0 * 2^4 == 0 *  16 ==   0
1 * 2^3 == 1 *   8 ==   8
0 * 2^2 == 0 *   4 ==   0
1 * 2^1 == 1 *   2 ==   2
0 * 2^0 == 0 *   1 ==   0
                      ---
                      234
                      ---


A common base in "computer speak" is base 16 - or hex because it's easy to work into binary for the computer, and also a lot shorter than binary!
For hex, we need sixteen digits: 0 to 9, plus six others, for which we use the alphabet: A, B, C, D, E, and F.
So 234 in Hex is "EA":

E == 14 in base ten * 16^1 == 14 * 16 == 224
A == 10 in base ten * 16^0 == 10 *  1 ==  10
                                         ---
                                         234
                                         ---


So... 128 in hex is 80:

8 * 16 ^ 1 == 8 * 16 == 128
0 * 16 ^ 0 == 0 *  1 ==   0
                        ---
                        128
                        ---


And you can work the rest out for yourself using the same principles! :laugh:


这篇关于我如何在javascript中理解和解决这些数学和数字示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆