Skip to content

mt19937 random module define the 'MIN' with value '1' #466

@zhangyufei49

Description

@zhangyufei49

Description

code lines

mt19937.MIN is 1 in stdlib-js
https://github.com/stdlib-js/random-base-mt19937/blob/6865e300633a39b23394ddbe74f027d919425e60/src/main.c?_pjax=%23js-repo-pjax-container#L136

static const struct BasePRNG mt19937_prng = {
	"mt19937",                                            // name
	(uint64_t)1,                                          // min <<==============
	(uint64_t)MAX_UINT32,                                 // max: (2^{32}-1)
	0.0,                                                  // min (normalized)
	MAX_NORMALIZED,                                       // max (normalized): (2^{53}-1)/2^{53}
	sizeof( stdlib_base_random_mt19937_state_t ),         // state_size
	&next,                                                // next()
	&normalized,                                          // normalized()
	&mt19937_free                                         // free()
};

But 0 in LLVM libc++ library:
https://github.com/llvm-mirror/libcxx/blob/78d6a7767ed57b50122a161b91f59f19c9bd0d19/include/random#L2078

class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine
{
public:
    // types
    typedef _UIntType result_type;

public:
    static _LIBCPP_CONSTEXPR const result_type _Min = 0; // <<=========
    static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
                                                      (result_type(1) << __w) - result_type(1);
    _LIBCPP_INLINE_VISIBILITY
    static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions