[jira] [Created] (FLINK-4668) Fix positive random int generation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-4668) Fix positive random int generation

Shang Yuanchun (Jira)
Alexander Pivovarov created FLINK-4668:
------------------------------------------

             Summary: Fix positive random int generation
                 Key: FLINK-4668
                 URL: https://issues.apache.org/jira/browse/FLINK-4668
             Project: Flink
          Issue Type: Bug
          Components: Client
            Reporter: Alexander Pivovarov
            Priority: Trivial


According to java spec
{code}Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE{code}

So, {code}Math.abs(rnd.nextInt()){code} might return negative value

To generate positive random int value we can use
{code}rnd.nextInt(Integer.MAX_VALUE){code}

Integer.MAX_VALUE will be excluded btw



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)