Skip to content

Random.Next returns negative numbers #405

@MatthiasJentsch

Description

@MatthiasJentsch

Details about Problem

nanoFramework area: nanoCLR preview 791 / nanoFramework.CoreLibrary preview 62

Worked before? No

Detailed repro steps so we can see the same problem

The Random.Next returns not only values >= 0. I think that's caused by the nanoFramework.CoreLibrary Random.Next implementation. There is the uint32 return value from the unmanged part returned as int32

In nanoFramework.CoreLibrary:

/// <summary>
/// Returns a nonnegative random number.
/// </summary>
/// <returns>A 32-bit signed integer greater than or equal to zero and
/// less than MaxValue.</returns>
[MethodImpl(MethodImplOptions.InternalCall)]
public virtual extern int Next();

But in nanoCLR the return type is uint32_t

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions