Skip to main content
Commonmark migration
Source Link

#Use Exponents

Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

Example

##Example TheThe maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

The above, though, may work out shorter if, for example, you already have Math aliased to a single character elsewhere in your code.

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

The above, though, may work out shorter if, for example, you already have Math aliased to a single character elsewhere in your code.

Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

Example

The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

The above, though, may work out shorter if, for example, you already have Math aliased to a single character elsewhere in your code.

added 140 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

The above, though, may work out shorter if, for example, you already have Math aliased to a single character elsewhere in your code.

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

The above, though, may work out shorter if, for example, you already have Math aliased to a single character elsewhere in your code.

added 105 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScriptmaximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1

#Use Exponents

If your language has an exponent operator you might be able to use it to generate, if not the number you want, at least a number you can perform a simple calculation or 2 on to arrive at your number. Even without an operator, you may still be able to save bytes with a built-in function or method.

##Example The maximum safe integer in JavaScript is 9007199254740991, which is 16 digits long. In ES7, this can be calculated with the following 7 bytes:

2**53-1

The equivalent in ES6 and earlier, while the same length as the integer itself in this instance, demonstrates that using a more verbose method might not necessarily cost you any bytes.

Math.pow(2,53)-1
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading