<commit_before>package com.common.android.utils.extensions;

import android.content.res.Resources;

import java.util.Random;

/**
 * Created by <NAME> on 24/09/15.
 */
final public class MathExtensions {

    private MathExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    /**
     * Returns a pseudo-random number between min and max, inclusive.
     * The difference between min and max can be at most
     * <code>Integer.MAX_VALUE - 1</code>.
     *
     * @param min Minimum value
     * @param max Maximum value.  Must be greater than min.
     * @return Integer between min and max, inclusive.
     * @see java.util.Random#nextInt(int)
     */
    public static int randInt(final int min, final int max) {

        // NOTE: Usually this should be a field rather than a method
        // variable so that it is not re-seeded every call.

        // nextInt is normally exclusive of the top value,
        // so add 1 to make it inclusive

        return new Random().nextInt((max - min) + 1) + min;
    }

    public static float clamp(final float val, final float min, final float max) {
        return Math.max(min, Math.min(max, val));
    }

    public static float pxToDp(final int px) {
        final float pixel = px;
        return (pixel / getDensity());
    }

    public static int dpToPx(final int dp) {
        final float scale = getDensity();
        return (int) (dp * scale + 0.5f);
    }

    public static int getDensityDpi() {
        return Resources.getSystem().getDisplayMetrics().densityDpi;
    }

    public static float getDensity() {
        return Resources.getSystem().getDisplayMetrics().density;
    }

    public static int roundToInt(final double v) {
        return (int) (v + 0.5);
    }
}<commit_msg>added float based dptopx and pxtodp methods<commit_after>package com.common.android.utils.extensions;

import android.content.res.Resources;

import java.util.Random;

/**
 * Created by <NAME> on 24/09/15.
 */
final public class MathExtensions {

    private MathExtensions() throws IllegalAccessException {
        throw new IllegalAccessException();
    }

    /**
     * Returns a pseudo-random number between min and max, inclusive.
     * The difference between min and max can be at most
     * <code>Integer.MAX_VALUE - 1</code>.
     *
     * @param min Minimum value
     * @param max Maximum value.  Must be greater than min.
     * @return Integer between min and max, inclusive.
     * @see java.util.Random#nextInt(int)
     */
    public static int randInt(final int min, final int max) {

        // NOTE: Usually this should be a field rather than a method
        // variable so that it is not re-seeded every call.

        // nextInt is normally exclusive of the top value,
        // so add 1 to make it inclusive

        return new Random().nextInt((max - min) + 1) + min;
    }

    public static float clamp(final float val, final float min, final float max) {
        return Math.max(min, Math.min(max, val));
    }

    public static int pxToDp(final int px) {
        final float pixel = px;
        return (int) (pixel / getDensity());
    }

    public static float pxToDp(final float px) {
        final float pixel = px;
        return (pixel / getDensity());
    }

    public static float dpToPx(final float dp) {
        final float scale = getDensity();
        return (dp * scale + 0.5f);
    }

    public static int dpToPx(final int dp) {
        final float scale = getDensity();
        return (int) (dp * scale + 0.5f);
    }

    public static int getDensityDpi() {
        return Resources.getSystem().getDisplayMetrics().densityDpi;
    }

    public static float getDensity() {
        return Resources.getSystem().getDisplayMetrics().density;
    }

    public static int roundToInt(final double v) {
        return (int) (v + 0.5);
    }

}
{'fraction_non_alphanumeric': 0.09902011346054668, 'fraction_numerical': 0.007220216606498195, 'mean_word_length': 2.429708222811671, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4234864', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1095, 'n_words': 396}