<commit_before>/**********************************************************************
 *
 * PROJECT:		Math library
 * FILE:		MathUtils.h
 * LICENCE:		See Licence.txt
 * PURPOSE:		Generic and useful math functions.
 *
 *				(c) <NAME> 2012
 *
 **********************************************************************/

#pragma once
#ifndef __MYLLY_MATH_UTILS_H
#define __MYLLY_MATH_UTILS_H

#include "stdtypes.h"

#define math_max(x, y)		((x) > (y) ? (x) : (y))
#define math_min(x, y)		((x) < (y) ? (x) : (y))
#define math_abs(x)			(((x) < 0) ? -(x) : (x))

static MYLLY_INLINE int32 math_clamp( int32 value, int32 lower, int32 upper )
{
	value = value > upper ? upper : value;
	return value < lower ? lower : value;
}

static MYLLY_INLINE float math_clampf( float value, float lower, float upper )
{
	value = value > upper ? upper : value;
	return value < lower ? lower : value;
}

#if defined _WIN32 && _MSC_VER < 1700

// VS implementation for sincosf that is missing from earlier versions of Visual C++
#include <math.h>

static MYLLY_INLINE void sincosf( float angle, float* fsin, float *fcos )
{
	*fsin = sinf( angle );
	*fcos = cosf( angle );<commit_msg>Make sure sincosf is defined on VS2012.<commit_after>/**********************************************************************
 *
 * PROJECT:		Math library
 * FILE:		MathUtils.h
 * LICENCE:		See Licence.txt
 * PURPOSE:		Generic and useful math functions.
 *
 *				(c) <NAME> 2012
 *
 **********************************************************************/

#pragma once
#ifndef __MYLLY_MATH_UTILS_H
#define __MYLLY_MATH_UTILS_H

#include "stdtypes.h"

#define math_max(x, y)		((x) > (y) ? (x) : (y))
#define math_min(x, y)		((x) < (y) ? (x) : (y))
#define math_abs(x)			(((x) < 0) ? -(x) : (x))

static MYLLY_INLINE int32 math_clamp( int32 value, int32 lower, int32 upper )
{
	value = value > upper ? upper : value;
	return value < lower ? lower : value;
}

static MYLLY_INLINE float math_clampf( float value, float lower, float upper )
{
	value = value > upper ? upper : value;
	return value < lower ? lower : value;
}

#if defined _WIN32

// VS implementation for sincosf that is missing from earlier versions of Visual C++
#include <math.h>

static MYLLY_INLINE void sincosf( float angle, float* fsin, float *fcos )
{
	*fsin = sinf( angle );
	*fcos = cosf( angle );
{'fraction_non_alphanumeric': 0.24086021505376345, 'fraction_numerical': 0.016344086021505378, 'mean_word_length': 4.434579439252336, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 13, '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': '7335868', 'n_tokens_mistral': 862, 'n_tokens_neox': 802, 'n_words': 248}