.ﺩﻮﺷ ﯽﻣ ﻩﺩﺎﻔﺘﺳﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮒﺭﺰﺑ ﺮﯾﺩﺎﻘﻣ ﻩﺮﯿﺧﺫ ﯼﺍﺮﺑ BigInt
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﯼﺎﻫﺮﯿﻐﺘﻣ
:ﺪﻨﺘﺴﻫ ﻖﯿﻗﺩ ﻢﻗﺭ 15 ﺎﺗ ﻂﻘﻓ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ
let x = 999999999999999;
let y = 9999999999999999;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>Integer Precision</h2>
<p>Integers (numbers without a period or exponent notation) are accurate up to 15 digits:</p>
<p id="demo"></p>
<script>
let x = 999999999999999;
let y = 9999999999999999;
document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>
</body>
</html>
.ﺪﻧﻮﺷ ﯽﻣ ﻩﺮﯿﺧﺫ (IEEE 754 ﺩﺭﺍﺪﻧﺎﺘﺳﺍ) ﯽﺘﯿﺑ 64 ﺭﻭﺎﻨﺷ ﺰﯿﻤﻣ ﺐﻟﺎﻗ ﺭﺩ ﺩﺍﺪﻋﺍ ﻡﺎﻤﺗ ،ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ
.ﺩﻮﺷ ﯽﻣ ﺩﺮﮔ ﻭ ﺩﺍﺩ ﻥﺎﺸﻧ ﺎًﻘﯿﻗﺩ ﻥﺍﻮﺗ ﯽﻤﻧ ﺍﺭ ﮒﺭﺰﺑ ﺢﯿﺤﺻ ﺩﺪﻋ ،ﺩﺭﺍﺪﻧﺎﺘﺳﺍ ﻦﯾﺍ ﺎﺑ
:ﺪﻫﺩ ﻥﺎﺸﻧ ﺍﺭ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ ﻦﻤﯾﺍ ﺭﻮﻃ ﻪﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﻂﻘﻓ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ،ﻞﯿﻟﺩ ﻦﯿﻤﻫ ﻪﺑ
b>9007199254740991 +(253-1)> ﺎﺗ ﺮﺜﮐﺍﺪﺣ
ﻭ
.b>-9007199254740991 -(253-1)> ﻪﺑ ﻦﯿﯾﺎﭘ
.ﺪﻨﻫﺩ ﯽﻣ ﺖﺳﺩ ﺯﺍ ﺍﺭ ﺖﻗﺩ ﻩﺩﻭﺪﺤﻣ ﻦﯾﺍ ﺯﺍ ﺝﺭﺎﺧ ﺢﯿﺤﺻ ﺮﯾﺩﺎﻘﻣ
.ﺪﯿﻨﮐ ﻪﻓﺎﺿﺍ ﯽﻧﺍﻮﺧﺍﺮﻓ ﺎﯾ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ ﯼﺎﻬﺘﻧﺍ ﻪﺑ ﺍﺭ code class="w3-codespan">BigInt، n> ﮏﯾ ﺩﺎﺠﯾﺍ ﯼﺍﺮﺑ
let x = 9999999999999999;
let y = 9999999999999999n;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>Integer and BigInt</h2>
<p id="demo"></p>
<script>
let x = 9999999999999999;
let y = BigInt("9999999999999999");
document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>
</body>
</html>
let x = 1234567890123456789012345n;
let y = BigInt(1234567890123456789012345)
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>Create a BigInt</h2>
<p id="demo"></p>
<script>
let x = 123456789012345678901234567890n;
let y = BigInt("123456789012345678901234567890");
document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>
</body>
</html>
ﻉﻮﻧ
a BigInt
ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ "bigint" ﺖﺳﺍ:
let x = BigInt(999999999999999);
let type = typeof x;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>BigInt typeof</h2>
<p>The typeof a BigInt is:</p>
<p id="demo"></p>
<script>
let x = BigInt("9999999999999999");
document.getElementById("demo").innerHTML = typeof x;
</script>
</body>
</html>
BigInt
ﺖﺳﺍ ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﯼﺩﺪﻋ ﻩﺩﺍﺩ ﻉﻮﻧ ﻦﯿﻣﻭﺩ
:ﺖﺳﺍ 8 ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﻩﺪﺷ ﯽﻧﺎﺒﯿﺘﺸﭘ ﯼﺎﻫ ﻩﺩﺍﺩ ﻉﺍﻮﻧﺍ ﻞﮐ ﺩﺍﺪﻌﺗ BigInt
ﺎﺑ
ﻪﺘﺷﺭ .1
ﺪﻧﻮﺷ ﻩﺩﺎﻔﺘﺳﺍ ﻩﺭﺎﻤﺷ<"code class="w3-codespan> ﺖﭙﯾﺮﮑﺳﺍ ﺍﻭﺎﺟ ﺭﺩ ﺪﻨﻧﺍﻮﺗ ﯽﻣ ﻪﮐ ﯽﯾﺎﻫﺭﻮﺗﺍﺮﭘﺍ
let x = 9007199254740995n;
let y = 9007199254740995n;
let z = x * y;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavScript Bigint</h1>
<h2>BigInt Multiply</h2>
<p>Operators that can be used a Number can be used on a BigInt.</p>
<p id="demo"></p>
<script>
let x = 9007199254740995n;
let y = 9007199254740995n;
let z = x * y;
document.getElementById("demo").innerHTML = z;
</script>
</body>
</html>
BigInt
ﻦﯿﺑ ﺏﺎﺴﺣ
ﺩﺍﺩ ﻡﺎﺠﻧﺍ BigInt
ﺭﺩ ﻥﺍﻮﺗ ﯽﻤﻧ ﺍﺭ (<<<) ﺖﺳﺍﺭ ﻪﺑ ﺎﻀﻣﺍ ﻥﻭﺪﺑ ﺮﯿﯿﻐﺗ
.ﺪﺷﺎﺑ ﺭﺎﺸﻋﺍ ﯼﺍﺭﺍﺩ ﺪﻧﺍﻮﺗ ﯽﻤﻧ BigInt
ﮏﯾ
let x = 5n;
let y = x / 2;
// Error: Cannot mix BigInt and other types, use explicit conversion.
let x = 5n;
let y = Number(x) / 2;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavScript Bigint</h1>
<h2>BigInt Divide</h2>
<p>A BigInt can not have decimals.</p>
<p>Cannot mix BigInt and other types, use explicit conversions.</p>
<p id="demo"></p>
<script>
let x = 5n;
let y = Number(x) / 2;
document.getElementById("demo").innerHTML = y;
</script>
</body>
</html>
BigInt
ﯽﻣ ﻦﯿﻨﭽﻤﻫﺖﺸﻫ ،ﻝﺎﻤﯿﺳﺩﺍﺰﮕﻫ ﺕﺭﻮﺻ ﻪﺑ ﺪﻧﺍﻮﺗﺩﻮﺷ ﻪﺘﺷﻮﻧ ﯼﺮﻨﯾﺎﺑ ﺎﯾ ﻪﻧﺎﮔ:
let hex = 0x20000000000003n;
let oct = 0o400000000000000003n;
let bin = 0b100000000000000000000000000000000000000000000000000011n;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavScript Bigint</h1>
<h2>Hex, Octal and Binary</h2>
<p id="demo"></p>
<script>
let hex = 0x20000000000003n;
let oct = 0o400000000000000003n;
let bin = 0b100000000000000000000000000000000000000000000000000011n;
document.getElementById("demo").innerHTML = hex + "<br>" + oct + "<br>" + bin;
</script>
</body>
</html>
:ﺩﺯﺍﺪﻨﯿﺑ ﺮﻄﺧ ﻪﺑ ﺍﺭ ﻪﻣﺎﻧﺮﺑ ﺖﯿﻨﻣﺍ ﺪﻧﺍﻮﺗ ﯽﻣ ﻥﺩﺮﮐ ﺩﺮﮔ
9007199254740992 === 9007199254740993; // is true !!!
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavScript Numbers</h1>
<h2>Integer Precision</h2>
<p>Is 9007199254740992 equal to 9007199254740993?</p>
<p id="demo"></p>
<script>
let x = 9007199254740992 === 9007199254740993;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
BigInt
ﯽﻣ ﯽﻧﺎﺒﯿﺘﺸﭘ ﺎﻫﺮﮔﺭﻭﺮﻣ ﻪﻤﻫ ﺭﺩ 2020 ﺮﺒﻣﺎﺘﭙﺳ ﺯﺍﺩﻮﺷ:
Chrome 67 | Edge 79 | Firefox 68 | Safari 14 | Opera 54 |
May 2018 | Jan 2020 | Jul 2019 | Sep 2020 | Jun 2018 |
ES6 ﯼﺎﻫ ﯽﮔﮋﯾﻭ max ﻭ min ﯽﺷ ﻪﺑ ﺍﺭ Number ﺩﺮﮐ ﻪﻓﺎﺿﺍ:
MAX_SAFE_INTEGER
MIN_SAFE_INTEGER
let x = Number.MAX_SAFE_INTEGER;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Number Object Properties</h2>
<p>MAX_SAFE_INTEGER</p>
<p id="demo"></p>
<script>
let x = Number.MAX_SAFE_INTEGER;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
let x = Number.MIN_SAFE_INTEGER;
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﺍﺭ ﻥﺁ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h2>Number Object Properties</h2>
<p>MIN_SAFE_INTEGER</p>
<p id="demo"></p>
<script>
let x = Number.MIN_SAFE_INTEGER;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
ES6 ﯽﺷ ﻪﺑ ﺍﺭ ﺪﯾﺪﺟ ﺵﻭﺭ 2 ﻦﯿﻨﭽﻤﻫ Number ﺩﺮﮐ ﻪﻓﺎﺿﺍ:
Number.isInteger()
Number.isSafeInteger()
.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ Number.isInteger()
true
ﺵﻭﺭ ،ﺪﺷ
Number.isInteger(10);
Number.isInteger(10.5);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isInteger() Method</h2>
<p>The isInteger() method returns true if the argument is an integer.</p>
<p>Otherwise it returns false.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
Number.isInteger(10) + "<br>" + Number.isInteger(10.5);
</script>
</body>
</html>
.ﺩﻮﺷ ﻩﺩﺍﺩ ﺶﯾﺎﻤﻧ ﺮﺑﺍﺮﺑ ﻭﺩ ﻖﯿﻗﺩ ﺩﺪﻋ ﮏﯾ ﻥﺍﻮﻨﻋ ﻪﺑ ﺪﻧﺍﻮﺗ ﯽﻣ ﺎﻘﯿﻗﺩ ﻪﮐ ﺖﺳﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ ﻦﻤﯾﺍ ﺢﯿﺤﺻ ﺩﺪﻋ ﮏﯾ
.ﺪﻧﺍﺩﺮﮔﯽﻣﺮﺑ ﺍﺭ Number.isSafeInteger()
true
ﺵﻭﺭ
Number.isSafeInteger(10);
Number.isSafeInteger(12345678901234567890);
→ ﺪﯿﻨﮐ ﻥﺎﺤﺘﻣﺍ ﻥﺎﺗﺩﻮﺧ
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Numbers</h1>
<h2>The isSafeInteger() Method</h2>
<p>The isSafeInteger() method returns true if the argument is a safe integer.</p>
<p>Otherwise it returns false.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
Number.isSafeInteger(10) + "<br>" + Number.isSafeInteger(12345678901234567890);
</script>
</body>
</html>
.ﺪﻨﺘﺴﻫ (sup>53 - 1>2)+ ﺎﺗ (sup>53 - 1>2)- ﺯﺍ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ ﻪﻤﻫ ﻦﻣﺍ ﺢﯿﺤﺻ ﺩﺍﺪﻋﺍ