<commit_before>// provides rand and RAND_MAX
#include <cstdlib>

#include "pi.h"

double distance_to_origin_squared(const double x, const double y)
{
    return x * x + y * y;
}

double approximate_pi_c(const int num_points)
{
    int num_inside = 0;

    for (int i = 0; i < num_points; i++)
    {
        double x = ((double)rand() / (RAND_MAX));
        double y = ((double)rand() / (RAND_MAX));
        if (distance_to_origin_squared(x, y) < 1.0)
        {
            num_inside++;
        }
    }

    // we multiply by 4 to get the full circle
    // from the 4 segments
    return 4.0 * num_inside / ((double)num_points);
}<commit_msg>make code easier to read<commit_after>// provides rand and RAND_MAX
#include <cstdlib>

#include "pi.h"

double distance_to_origin_squared(const double x, const double y)
{
    return x * x + y * y;
}

double approximate_pi_c(const int num_points)
{
    int num_inside = 0;

    for (int i = 0; i < num_points; i++)
    {
        double x = ((double)rand() / (RAND_MAX));
        double y = ((double)rand() / (RAND_MAX));

        if (distance_to_origin_squared(x, y) < 1.0) num_inside++;
    }

    // we multiply by 4 to get the full circle from the 4 segments
    return 4.0 * num_inside / ((double)num_points);
}
{'fraction_non_alphanumeric': 0.12867355043685463, 'fraction_numerical': 0.012708498808578236, 'mean_word_length': 2.652173913043478, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '3562025', 'n_tokens_mistral': 471, 'n_tokens_neox': 434, 'n_words': 134}