<commit_before>package com.carrotsearch.hppc;

import java.util.Random;

/**
 * XorShift pseudo random number generator. This class is not thread-safe and should be
 * used from a single thread only.
 * 
 * @see "http://en.wikipedia.org/wiki/Xorshift"
 * @see "http://www.jstatsoft.org/v08/i14/paper"
 * @see "http://www.javamex.com/tutorials/random_numbers/xorshift.shtml"
 */
@SuppressWarnings("serial")
public class XorShiftRandom extends Random
{
    private long x;

    public XorShiftRandom()
    {
        this(System.nanoTime());
    }

    public XorShiftRandom(long seed)
    {
        this.setSeed(seed);
    }

    @Override
    public long nextLong()
    {
        x ^= (x << 21);
        x ^= (x >>> 35);
        x ^= (x << 4);
        return x;
    }

    @Override
    protected int next(int bits)
    {
        return (int)(nextLong() >>> (48 - bits));
    }

    @Override
    public void setSeed(long seed)
    {
        this.x = seed;
    }
}
<commit_msg>Fixed a bug in XorShift that could result in negative nextInt(n) values.<commit_after>package com.carrotsearch.hppc;

import java.util.Random;

/**
 * XorShift pseudo random number generator. This class is not thread-safe and should be
 * used from a single thread only.
 * 
 * @see "http://en.wikipedia.org/wiki/Xorshift"
 * @see "http://www.jstatsoft.org/v08/i14/paper"
 * @see "http://www.javamex.com/tutorials/random_numbers/xorshift.shtml"
 */
@SuppressWarnings("serial")
public class XorShiftRandom extends Random
{
    private long x;

    public XorShiftRandom()
    {
        this(System.nanoTime());
    }

    public XorShiftRandom(long seed)
    {
        this.setSeed(seed);
    }

    @Override
    public long nextLong()
    {
        x ^= (x << 21);
        x ^= (x >>> 35);
        x ^= (x << 4);
        return x;
    }

    @Override
    protected int next(int bits)
    {
        return ((int) nextLong() >>> (48 - bits));
    }

    @Override
    public void setSeed(long seed)
    {
        this.x = seed;
    }
}

{'fraction_non_alphanumeric': 0.13667992047713717, 'fraction_numerical': 0.010934393638170975, 'mean_word_length': 2.3438538205980066, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6202386', 'n_tokens_mistral': 710, 'n_tokens_neox': 677, 'n_words': 164}