<commit_before>#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <endian.h>
#include <stdlib.h>
#include <float.h>

union doubleBits {
	double dbl;
	struct {
#if _BYTE_ORDER == _LITTLE_ENDIAN
		unsigned int mantissaLow:32;
		unsigned int mantissaHigh:20;
		unsigned int exponent:11;
		unsigned int sign:1;
#else
		unsigned int sign:1;
		unsigned int exponent:11;
		unsigned int mantissaHigh:20;
		unsigned int mantissaLow:32;
#endif
	} components;
};

struct dblstring {
	union stupid_stuff {
		double dbl;
		char string[8];
	}stupid;
	char end;
};

double frexp(double x, int *exp);

int main(int argc, char **argv)
{

	double number;
	double mantissa;
	int exponent;
	struct dblstring charstr;

	printf("Enter a number:\n");
	scanf("%lf", &number);

	mantissa = frexp(number, &exponent);

	/* Double, what is mantissa? */
	printf("Treated as a double, mantissa =\t %lf\n", mantissa);

	/* Double, what is sign */
	printf("Treated as a double, sign =\t  %s\n", (number < 0) ? "negative" : "positive");

	/* Double, what is exponent? */
	printf("Treated as a double, exponent =\t %d\n", exponent);

	/* Long, value? */
	printf("Treated as a long, the value =\t %ld\n", (long)number);

	/* Long, sign? */
	printf("Treated as a long, sign =\t %s\n", ((long)number < 0) ? "negative" : "positive");

	/* 8 chars */
	charstr.stupid.dbl = number;
	charstr.end = '\0';
	printf("Treated as 8 characters =\t %s\n", charstr.stupid.string);

	exit(EXIT_SUCCESS);
}

double frexp(double x, int *exp)
{

	union doubleBits number;

	number.dbl = x;

	switch(number.components.exponent){
	case 0:
		/* 0 or subnormal value */
		if(!(number.components.mantissaLow | number.components.mantissaHigh)){
			*exp = 0;
		} else {
			number.dbl *= 0x1.0p514; /* this is a magic number, clarify it's use */
			*exp = number.components.exponent - 1536;
			number.components.exponent = 1022;<commit_msg>Clarified magic number and its use.<commit_after>#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <endian.h>
#include <stdlib.h>
#include <float.h>

union doubleBits {
	double dbl;
	struct {
#if _BYTE_ORDER == _LITTLE_ENDIAN
		unsigned int mantissaLow:32;
		unsigned int mantissaHigh:20;
		unsigned int exponent:11;
		unsigned int sign:1;
#else
		unsigned int sign:1;
		unsigned int exponent:11;
		unsigned int mantissaHigh:20;
		unsigned int mantissaLow:32;
#endif
	} components;
};

struct dblstring {
	union stupid_stuff {
		double dbl;
		char string[8];
	}stupid;
	char end;
};

double frexp(double x, int *exp);

int main(int argc, char **argv)
{

	double number;
	double mantissa;
	int exponent;
	struct dblstring charstr;

	printf("Enter a number:\n");
	scanf("%lf", &number);

	mantissa = frexp(number, &exponent);

	/* Double, what is mantissa? */
	printf("Treated as a double, mantissa =\t %lf\n", mantissa);

	/* Double, what is sign */
	printf("Treated as a double, sign =\t  %s\n", (number < 0) ? "negative" : "positive");

	/* Double, what is exponent? */
	printf("Treated as a double, exponent =\t %d\n", exponent);

	/* Long, value? */
	printf("Treated as a long, the value =\t %ld\n", (long)number);

	/* Long, sign? */
	printf("Treated as a long, sign =\t %s\n", ((long)number < 0) ? "negative" : "positive");

	/* 8 chars */
	charstr.stupid.dbl = number;
	charstr.end = '\0';
	printf("Treated as 8 characters =\t %s\n", charstr.stupid.string);

	exit(EXIT_SUCCESS);
}

double frexp(double x, int *exp)
{

	union doubleBits number;

	number.dbl = x;

	switch(number.components.exponent){
	case 0:
		/* 0 or subnormal value */
		if(!(number.components.mantissaLow | number.components.mantissaHigh)){
			*exp = 0;
		} else {
			number.dbl *= 0x1.0p514; /* 2^64, restores the number. */
			*exp = number.components.exponent - 1536;
			number.components.exponent = 1022;
{'fraction_non_alphanumeric': 0.15597287428273343, 'fraction_numerical': 0.020083463745435577, 'mean_word_length': 3.891581632653061, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '45229', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1389, 'n_words': 402}