How to use the @mathigon/fermat.numberFormat function in @mathigon/fermat

To help you get started, we’ve selected a few @mathigon/fermat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mathigon / textbooks / content / exploding-dots / components / dot-machine.ts View on Github external
constructor(private readonly $dotMachine: DotMachine, initial = 0,
              index = 0) {
    super();
    this.value = initial;

    this.$el = $N('div', {class: 'dot-cell'}, $dotMachine.$wrap);
    this.$value = $N('div', {class: 'cell-value', html: initial}, this.$el);

    const order = numberFormat(index > 0 ? Math.pow($dotMachine.base, index) :
                               1 / Math.pow($dotMachine.base, -index));  // Prevent rounding errors
    $N('div', {class: 'cell-order', html: order}, this.$el);

    if (initial) {
      this.rearrange(initial);
      for (let i = 0; i < initial; ++i) this.addDot(undefined, {count: false});
    }
  }
github mathigon / textbooks / content / circles / functions.ts View on Github external
function numberAnimation(n: number, $el: ElementView, t: number) {
  const digits = numberFormat(n).split('');
  const length = digits.length;

  return animate((p) => {
    const num = digits.map((n, i) => {
      if (i > p * length + 1) return '';
      if (isOneOf(n, ',', '.')) return n;
      if (i > p * length - 1) return Random.integer(10);
      return n;
    });
    $el.text = num.join('');
  }, t);
}
github mathigon / textbooks / content / graph-theory / functions.js View on Github external
$section.model.set('tsnPaths', function(x) {
    return list(x, 1).join(' × ') + ' = ' + numberFormat(factorial(x));
  });
}
github mathigon / textbooks / content / graph-theory / functions.ts View on Github external
$section.model.set('tsnPaths', (x: number) => {
    return list(x, 1).join(' × ') + ' = ' + numberFormat(factorial(x));
  });
}
github mathigon / textbooks / content / divisibility / functions.ts View on Github external
        .then((result) => $section.model.set('result', numberFormat(result)))
        .catch(() => $section.model.set('result', `Couldn‘t find a prime :(`));
github mathigon / textbooks / content / divisibility / functions.js View on Github external
        .then(({data}) => $section.model.set('result', numberFormat(data)))
        .catch(() => $section.model.set('result', `Couldn‘t find a prime :(`));
github mathigon / textbooks / content / graph-theory / functions.js View on Github external
  $section.model.set('factorial', x => numberFormat(factorial(x)));
}
github mathigon / textbooks / content / sequences / functions.ts View on Github external
      (a: number, d: number, i: number) => numberFormat(a + i * d, 4));
github mathigon / textbooks / content / exploding-dots / functions.ts View on Github external
    pow: (n: number) => numberFormat(Math.pow(2, n)),
    nines: (n: number) => '0.' + '9'.repeat(Math.ceil(n * log2))