JAVASCRIPT Tutorial

Numbers

Introduction:

Numbers are essential tools for representing numerical values in programming. In Javascript, we have different types of numbers to cater to various mathematical operations.

Key Concepts:

  • Integers: Whole numbers without decimals, like 5, -10, or 0.
  • Floating-Point Numbers: Numbers with decimals, like 3.14, -1.23e-5, or 9.99999999999999.
  • Exponential Notation: A compact way to represent large or small numbers using powers of 10. For example, 3.14e-5 = 0.0000314.

Javascript Example:

// Represents numerical values
let integer = 10;
let float = 3.14;
let exponential = 1.23e-5;

console.log('Integer:', integer);  // Output: Integer: 10
console.log('Float:', float);  // Output: Float: 3.14
console.log('Exponential:', exponential);  // Output: Exponential: 1.23e-5

Additional Notes:

  • Integers can be positive, negative, or zero.
  • Floating-point numbers can also be called real numbers.
  • Pay attention to precision when using floating-point numbers, especially in calculations.
  • Use exponential notation when dealing with very large or small numbers for readability and efficiency.