embutils.utils.math module

Math utilities.

date

2021

author

Christian Wiche

contact

cwichel@gmail.com

license

The MIT License (MIT)

embutils.utils.math.closest_multi(ref: float, base: float, force_next: bool = False) float[source]

Computes the closest multiple of ‘base’ based on a given reference.

Parameters
  • ref (float) – Reference.

  • base (float) – Multiple base.

  • force_next (bool) – If reference is equal to multiple, forces next multiple.

Returns

Closest multiple.

Return type

float

embutils.utils.math.closest_pow(ref: float, base: float, force_next: bool = False) float[source]

Computes the closest power of ‘base’ based on a given reference.

Parameters
  • ref (float) – Reference

  • base (float) – Exponential base

  • force_next (bool) – If reference is equal to power of base, forces next power.

Returns

Closest power.

Return type

float