maTH
  • 👋Welcome!
  • 🗿Installation
  • Reference
    • 😱Mathematical operations
      • add
      • pascal
      • factorial
      • factorialL
      • GCD
      • LCM
      • pow
      • permutations
      • combinations
      • combinationsWithRep
      • subtract
      • multiply
      • divide
      • sin
      • cos
      • ln
      • log
      • radToDeg
      • degToRad
      • mod
      • abs
      • floor
      • ceil
      • root
      • exp
      • tan
      • arcsin
      • arccos
      • arctan
      • sinh
      • cosh
      • round
    • 🥶Statistics
      • Binomial
      • Poisson
      • Geometric
      • Pascal
      • Hypergeometric
      • Exponential
      • Uniform
    • 🥵Data structures
      • Stack
      • Queue
      • LinkedList
    • 🤓Algorithms
      • Bubble sort
      • Insertion sort
      • Selection sort
      • Merge sort
      • Quicksort
      • Heap sort
      • Count sort
      • Bucket sort
      • Radix sort
    • 😳Constants
Powered by GitBook
On this page
  1. Reference
  2. Mathematical operations

divide

PreviousmultiplyNextsin

Last updated 11 months ago

Divide any two numbers

divide<return_type>(a, b);

will return the quotient of the two given numbers. The return_type specifies in which data type the result will be returned in, like shown in below example:

divide<int>(12, 3.53); //4
divide<float>(3.002, 3.522); //0.852357
divide<bool>(0, 2); //0
------------------------
divide<char>('z', 2); //'='

Typically division works only for numeric data types, but in this case, you have an additional option for characters. Before using it in that way, please test it before actually implementing something.

Also be careful of the denominator being zero, because the compiler won't tell you that it is! It's not a bug, it's a feature.

😱
😉