[erlang-questions] Math pow

David Sveningsson ext@REDACTED
Fri Apr 3 15:29:58 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hasan Veldstra wrote:
> On 3 Apr 2009, at 13:49PM, Kunthar wrote:
> 
>> New shell R13A:
>>> random:uniform(math:pow(2, 48)).
>> ** exception error: no function clause matching
>> random:uniform(281474976710656.0)
>>
>> Old shell R12B:
>>> random:uniform(math:pow(2, 48)).
>> 44982915740374
>>
>> Any comments?
> 
> A guess – random:uniform does not accept floats anymore?

Correct, it doesn't accept floats any more, but strangely enough still
truncates the input:

- -spec uniform(pos_integer()) -> pos_integer().
uniform(N) when is_integer(N), N >= 1 ->
    trunc(uniform() * N) + 1.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknWD1YACgkQ6pa1H/H5pqXKiACg2xBUP0/AHVgUq3voHCY6Wzhn
Km8AoIF8GqFNzbCLHwCZnzFBLctv46mT
=34PM
-----END PGP SIGNATURE-----



More information about the erlang-questions mailing list