You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex D Herbert (JIRA)" <ji...@apache.org> on 2019/03/06 16:04:00 UTC

[jira] [Created] (RNG-81) NumberFactory

Alex D Herbert created RNG-81:
---------------------------------

             Summary: NumberFactory
                 Key: RNG-81
                 URL: https://issues.apache.org/jira/browse/RNG-81
             Project: Commons RNG
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.3
            Reporter: Alex D Herbert
            Assignee: Alex D Herbert
             Fix For: 1.3


Change the number factory methods for {{nextFloat}} and {{nextDouble}}. 

Currently the methods use:
 * 23-bits of state from an int to create a float
 * 52-bits of state from a long to create a double

This method produces output floating point numbers with the final bit of the mantissa set to 0. The methods can be changed to use 24-bits and 53-bits of state respectively.

This will match the implementation in {{java.util.SplittableRandom}}.

Benchmarking has shown no noticeable difference in speed.

Note that this change modifies the output {{float}} to evenly sample all {{k/2^-24}} [dyadic rationals|https://en.wikipedia.org/wiki/Dyadic_rational] and the {{double}} to evenly sample all {{k/2^-53}} dyadic rationals, i.e. the maximum number representable between 0 (inclusive) and 1.0 (exclusive).

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)