From 94c19ddfadc7879994db28812d4c6f23834f94ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=ADlvia=20Fonseca?= Date: Mon, 4 Oct 2021 23:39:42 -0300 Subject: [PATCH] content: add new math suggestion --- contents/algorithms/math.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contents/algorithms/math.md b/contents/algorithms/math.md index f3a05c15..81a20885 100644 --- a/contents/algorithms/math.md +++ b/contents/algorithms/math.md @@ -13,6 +13,9 @@ Check for and handle overflow/underflow if you are using a typed language like J Consider negative numbers and floating point numbers. This may sound obvious, but under interview pressure, many obvious cases go unnoticed. +When dealing with floating point numbers, avoid rounding mistakes by using epsilon comparison instead of equality check. + - E.g. `abs(x - y) <= 10e7` instead of `x == y`) + If the question asks to implement an operator such as power, squareroot or division and want it to be faster than O(n), binary search is usually the approach to go. #### Some common formulas: