mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-20 05:34:47 +00:00
move sqr and pow2 to math
This commit is contained in:
parent
533934fb16
commit
eafbfd0d6f
4 changed files with 22 additions and 100 deletions
|
@ -18963,14 +18963,6 @@ void sub_file_line_input_string(int32 fileno, qbs *deststr) {
|
|||
return;
|
||||
}
|
||||
|
||||
double func_sqr(double value) {
|
||||
if (value < 0) {
|
||||
error(5);
|
||||
return 0;
|
||||
}
|
||||
return std::sqrt(value);
|
||||
}
|
||||
|
||||
int32 shell_call_in_progress = 0;
|
||||
|
||||
#ifdef QB64_WINDOWS
|
||||
|
@ -20464,16 +20456,6 @@ shell_complete:;
|
|||
|
||||
} //_DONTWAIT & _HIDE
|
||||
|
||||
long double pow2(long double x, long double y) {
|
||||
if (x < 0) {
|
||||
if (y != std::floor(y)) {
|
||||
error(5);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return std::pow(x, y);
|
||||
}
|
||||
|
||||
int32 func_freefile() { return gfs_fileno_freefile(); }
|
||||
|
||||
void sub__mousehide() {
|
||||
|
|
|
@ -10,6 +10,9 @@ long double func_fix_float(long double value);
|
|||
double func_exp_single(double value);
|
||||
long double func_exp_float(long double value);
|
||||
|
||||
double func_sqr(double value);
|
||||
long double pow2(long double x, long double y);
|
||||
|
||||
// force abs to return floating point numbers correctly
|
||||
static inline double func_abs(double d) { return std::fabs(d); }
|
||||
static inline long double func_abs(long double d) { return std::fabs(d); }
|
||||
|
|
|
@ -45,3 +45,22 @@ long double func_exp_float(long double value) {
|
|||
error(6);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double func_sqr(double value) {
|
||||
if (value < 0) {
|
||||
error(5);
|
||||
return 0;
|
||||
}
|
||||
return std::sqrt(value);
|
||||
}
|
||||
|
||||
long double pow2(long double x, long double y) {
|
||||
if (x < 0) {
|
||||
if (y != std::floor(y)) {
|
||||
error(5);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return std::pow(x, y);
|
||||
}
|
||||
|
||||
|
|
|
@ -399,8 +399,6 @@ extern int64 func_loc(int32 i);
|
|||
extern qbs *func_input(int32 n, int32 i, int32 passed);
|
||||
extern int32 func__statusCode(int32 handle);
|
||||
|
||||
extern double func_sqr(double value);
|
||||
extern long double pow2(long double x, long double y);
|
||||
extern int32 func_freefile();
|
||||
extern void sub__mousehide();
|
||||
extern void sub__mouseshow(qbs *style, int32 passed);
|
||||
|
@ -666,86 +664,6 @@ inline ptrszint array_check(uptrszint index, uptrszint limit) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline int32 func_sgn(uint8 v) {
|
||||
if (v)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(int8 v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(uint16 v) {
|
||||
if (v)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(int16 v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(uint32 v) {
|
||||
if (v)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(int32 v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(uint64 v) {
|
||||
if (v)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(int64 v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(float v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(double v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
inline int32 func_sgn(long double v) {
|
||||
if (v)
|
||||
if (v > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
// Working with 32bit colors:
|
||||
inline uint32 func__rgb32(int32 r, int32 g, int32 b, int32 a) {
|
||||
if (r < 0)
|
||||
|
|
Loading…
Reference in a new issue