Exoddic v0.0.1 Exoddic

This module provides a means for working with odds and probability. In particular, it provides a means to convert between different representations.

Summary

Functions

convert values among the various provided odds formats

Functions

convert(amount, options \\ [])

Specs

convert(number | String.t, from: atom, to: atom, for_display: boolean) ::
  String.t |
  number

convert values among the various provided odds formats.

The to and from formats are identified by atoms as described below:

  • :prob is the implied probability. Formatted as precisely as possible.
  • :us is American-style “moneyline odds”. Formatted to the nearest integer.
  • :uk is UK-style “traditional odds”. Formatted as an integer ratio, with a denominator up to 1000.
  • :eu is European-style “decimal odds”. Formatted to three decimal places.
  • :id is Indonesian-style odds. Formatted to three decimal places.
  • :my is Malaysian-style odds. Formatted to three decimal places.
  • :hk is Hong Kong-style odds. Formatted to three decimal places.

Conversion amounts provided as strings will receive a best effort attempt at conversion to an appropriate number. Care should be taken to provide the appropriate number format for the chosen from. Converting to and from the same format with an appropriate for_display setting should provide insight into the conversion formats.

for_display defaults to true and will return an appropriately formatted string for the requested item. If set to false, it will return an unformatted number.