Checked doubling of a signed 64-bit integer, loaded from priv/native/libtwice.so.
The native file imports the generated ABI. It does not declare ErlNifFunc
or ErlNifEntry.
Summary
Functions
Returns 2 * n when n and the product fit in a signed 64-bit integer.
Loads priv/native/libtwice.so.
Types
Functions
Returns 2 * n when n and the product fit in a signed 64-bit integer.
n is an integer. There is no optional argument.
Returns
The product, an integer.
Raises
ArgumentErrorwhennis not an integer, does not fit in signed 64 bits, or2 * nwould overflow
Examples
iex> Mojoler.Twice.double(21)
42
iex> Mojoler.Twice.double(0)
0
iex> Mojoler.Twice.double(-3)
-6
iex> Mojoler.Twice.double(:nope)
** (ArgumentError) argument error
iex> Mojoler.Twice.double(9_223_372_036_854_775_807)
** (ArgumentError) argument error
@spec load_nif() :: :ok | {:error, term()}
Loads priv/native/libtwice.so.
A second call in the same VM returns {:error, {:reload, charlist}}.
Examples
iex> Mojoler.Twice.load_nif()
{:error, {:reload, ~c"NIF library already loaded (reload disallowed since OTP 20)."}}