diff --git a/lib/framework/math_ext.h b/lib/framework/math_ext.h index f16567b61..5e9edcf67 100644 --- a/lib/framework/math_ext.h +++ b/lib/framework/math_ext.h @@ -155,7 +155,7 @@ static inline void solveDifferential2ndOrder(float *y_, float *dydt_, float acce y = complexDouble(*y_, 0); dydt = complexDouble(*dydt_, 0); - sqd = d > 0? complexDouble(sqrt(d), 0) : complexDouble(0, sqrt(-d)); // sqd = std::sqrt(d); + sqd = d > 0? complexDouble(sqrt((double)d), 0) : complexDouble(0, sqrt((double)-d)); // sqd = std::sqrt(d); h1 = complexDoubleAdd(complexDouble(-friction/2, 0), sqd); // h1 = -friction/2 + sqd; h2 = complexDoubleSub(complexDouble(-friction/2, 0), sqd); // h2 = -friction/2 - sqd; e1 = complexDoubleExp(complexDoubleMul(h1, complexDouble(dt, 0))); // e1 = std::exp(h1*dt); diff --git a/lib/framework/trig.cpp b/lib/framework/trig.cpp index 2cf481551..92656e778 100644 --- a/lib/framework/trig.cpp +++ b/lib/framework/trig.cpp @@ -150,7 +150,7 @@ uint16_t iAtan2(int32_t s, int32_t c) int32_t iSqrt(uint32_t n) { - uint32_t r = sqrt(n); // Calculate square root, rounded down. Excess precision does not change the result. + uint32_t r = sqrt((double)n); // Calculate square root, rounded down. Excess precision does not change the result. // Check that we got the right result. ASSERT((int32_t)(r*r - n) <= 0 && (int32_t)((r + 1)*(r + 1) - n) > 0, "Too badly broken sqrt function, iSqrt(%u) = %u.", (unsigned)n, (unsigned)r); @@ -163,7 +163,7 @@ int32_t i64Sqrt(uint64_t n) uint64_t r; if (sizeof(void *) > 4) { - r = sqrt(n); // Calculate square root, usually rounded down. Excess precision may result in rounding down instead of up, which is fine. + r = sqrt((double)n); // Calculate square root, usually rounded down. Excess precision may result in rounding down instead of up, which is fine. } else { diff --git a/lib/ivis_common/imdload.cpp b/lib/ivis_common/imdload.cpp index 4dff46510..8d2fa6bec 100644 --- a/lib/ivis_common/imdload.cpp +++ b/lib/ivis_common/imdload.cpp @@ -425,7 +425,7 @@ static BOOL _imd_load_points( const char **ppFileData, iIMDShape *s ) dz = dia2.z - cen.z; rad_sq = dx*dx + dy*dy + dz*dz; - rad = sqrt(rad_sq); + rad = sqrt((double)rad_sq); // second pass (find tight sphere) for (p = s->points; p < s->points + s->npoints; p++) @@ -439,7 +439,7 @@ static BOOL _imd_load_points( const char **ppFileData, iIMDShape *s ) if (old_to_p_sq>rad_sq) { // this point outside current sphere - old_to_p = sqrt(old_to_p_sq); + old_to_p = sqrt((double)old_to_p_sq); // radius of new sphere rad = (rad + old_to_p) / 2.; // rad**2 for next compare diff --git a/src/main.cpp b/src/main.cpp index f9dde9f7d..51cfb6100 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1123,7 +1123,7 @@ static bool fptest2(void) wtf = true; break; } - b = 1/sqrt(b - (unsigned)b); + b = 1/sqrt((double)(b - (unsigned)b)); } for (n = 0; n != 100; ++n) { diff --git a/src/map.cpp b/src/map.cpp index e4a21fd41..b3be033b8 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -115,9 +115,6 @@ typedef struct _zonemap_save_header { // Maximum expected return value from get height #define MAX_HEIGHT (256 * ELEVATION_SCALE) -/* Number of entries in the sqrt(1/(1+x*x)) table for aaLine */ -#define ROOT_TABLE_SIZE 1024 - /* The size and contents of the map */ SDWORD mapWidth = 0, mapHeight = 0; MAPTILE *psMapTiles = NULL; diff --git a/src/terrain.cpp b/src/terrain.cpp index 745bf0102..87af59fad 100644 --- a/src/terrain.cpp +++ b/src/terrain.cpp @@ -718,8 +718,8 @@ bool initTerrain(void) debug(LOG_TERRAIN, "GL_MAX_ELEMENTS_INDICES: %i", (int)GLmaxElementsIndices); // now we know these values, determine the maximum sector size achievable - maxSectorSizeVertices = sqrt(GLmaxElementsVertices/2)-1; - maxSectorSizeIndices = sqrt(GLmaxElementsIndices/12); + maxSectorSizeVertices = iSqrt(GLmaxElementsVertices/2)-1; + maxSectorSizeIndices = iSqrt(GLmaxElementsIndices/12); debug(LOG_TERRAIN, "preferred sector size: %i", sectorSize); debug(LOG_TERRAIN, "maximum sector size due to vertices: %i", maxSectorSizeVertices);