[Solved] Formula to squash big numbers but keep smaller numbers in range 1 to 100


The described behavior reminds me of a root function. it doesn’t affect numbers that are small but the larger numbers we insert into the function, the more it gets squashed down.

You can vary the “factor of squashing” by multiplying x with a coefficient

Alternatively, you can use a logarithmic function which is the reverse of an exponential. This results in an even greater squashing effect

function m_n_chips(actual_chips: number) {
  if (actual_chips < 4) { return actual_chips }

  result = Math.sqrt(4 * x);
  // other option: use logarithm
  // result = Math.log(x) / Math.log(4);

  return Math.round(result);
}

When returning we convert the result to the nearest integer.

Hope that helps!

(Btw: For the future please provide more information e.g language, project details and how you came to your question)

solved Formula to squash big numbers but keep smaller numbers in range 1 to 100