Skip to content

手写获取随机数函数 #23

Open

Description

@Hongbusi
function getRandom (min, max) {
  return Math.floor(Math.random() * Math.abs(max - min + 1) + min)
}

Activity

  1. Rainer-Yu commented on Jun 28, 2022

    @Rainer-Yu
    function getRandom() {
        const ran = parseInt(10*Math.random())
        const ran2 = parseInt(10*Math.random())+1
        const temp = crypto.getRandomValues(new Uint32Array(ran))[ran-1]
        return parseInt((temp+'').substring(0,ran2))
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions