2021-09-15 23:24:19 +00:00
|
|
|
#ifndef MATH_H
|
|
|
|
#define MATH_H
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2022-11-13 07:16:01 +00:00
|
|
|
#include "ultra64/ultratypes.h"
|
2020-10-03 15:22:44 +00:00
|
|
|
|
2020-03-17 04:31:30 +00:00
|
|
|
#define M_PI 3.14159265358979323846f
|
2020-03-21 02:09:42 +00:00
|
|
|
#define M_SQRT2 1.41421356237309504880f
|
2023-10-27 14:06:44 +00:00
|
|
|
#define MAXFLOAT 3.40282347e+38f
|
2020-04-19 03:28:24 +00:00
|
|
|
#define SHT_MAX 32767.0f
|
|
|
|
#define SHT_MINV (1.0f / SHT_MAX)
|
2020-03-17 04:31:30 +00:00
|
|
|
|
2023-10-27 14:06:44 +00:00
|
|
|
float floorf(float);
|
|
|
|
double floor(double);
|
|
|
|
long lfloorf(float);
|
|
|
|
long lfloor(double);
|
2020-07-07 00:15:01 +00:00
|
|
|
|
2023-10-27 14:06:44 +00:00
|
|
|
float ceilf(float);
|
|
|
|
double ceil(double);
|
|
|
|
long lceilf(float);
|
|
|
|
long lceil(double);
|
2020-07-07 00:15:01 +00:00
|
|
|
|
2023-10-27 14:06:44 +00:00
|
|
|
float truncf(float);
|
|
|
|
double trunc(double);
|
|
|
|
long ltruncf(float);
|
|
|
|
long ltrunc(double);
|
2020-07-07 00:15:01 +00:00
|
|
|
|
2023-10-27 14:06:44 +00:00
|
|
|
float nearbyintf(float);
|
|
|
|
double nearbyint(double);
|
|
|
|
long lnearbyintf(float);
|
|
|
|
long lnearbyint(double);
|
|
|
|
|
|
|
|
float roundf(float);
|
|
|
|
double round(double);
|
|
|
|
long lroundf(float);
|
|
|
|
long lround(double);
|
|
|
|
|
2024-06-19 04:00:23 +00:00
|
|
|
f32 fabsf(f32 f);
|
|
|
|
#ifdef __sgi
|
|
|
|
#pragma intrinsic(fabsf)
|
|
|
|
#else
|
|
|
|
#define fabsf(f) __builtin_fabsf((f32)(f))
|
|
|
|
#endif
|
|
|
|
|
2024-09-04 05:12:44 +00:00
|
|
|
f64 fabs(f64 f);
|
|
|
|
#ifdef __sgi
|
|
|
|
#pragma intrinsic(fabs)
|
|
|
|
#else
|
|
|
|
#define fabs(f) __builtin_fabs((f64)(f))
|
|
|
|
#endif
|
|
|
|
|
2024-06-19 04:00:23 +00:00
|
|
|
f32 sqrtf(f32 f);
|
2024-08-23 07:11:41 +00:00
|
|
|
// IDO has a sqrtf intrinsic, but in N64 versions it's not used for some files.
|
|
|
|
// For these files we define NO_SQRTF_INTRINSIC to use the sqrtf function instead.
|
|
|
|
#if defined(__sgi) && !defined(NO_SQRTF_INTRINSIC)
|
2024-06-19 04:00:23 +00:00
|
|
|
#pragma intrinsic(sqrtf)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
f64 sqrt(f64 f);
|
|
|
|
#ifdef __sgi
|
|
|
|
#pragma intrinsic(sqrt)
|
|
|
|
#endif
|
|
|
|
|
2024-09-06 09:18:59 +00:00
|
|
|
#if !PLATFORM_N64
|
2023-10-27 14:06:44 +00:00
|
|
|
extern float qNaN0x3FFFFF;
|
|
|
|
extern float qNaN0x10000;
|
|
|
|
extern float sNaN0x3FFFFF;
|
2024-09-04 05:12:44 +00:00
|
|
|
#endif
|
2020-07-07 00:15:01 +00:00
|
|
|
|
2020-03-17 04:31:30 +00:00
|
|
|
#endif
|