| 6418 | } |
| 6419 | |
| 6420 | txInteger fxNumberToInteger(txNumber theValue) |
| 6421 | { |
| 6422 | #if defined(pebble) |
| 6423 | if (c_fpclassify(theValue) == C_FP_NORMAL) { |
| 6424 | #define MODULO 4294967296.0 |
| 6425 | txNumber aNumber = c_fmod(c_trunc(theValue), MODULO); |
| 6426 | if (aNumber >= MODULO / 2) |
| 6427 | aNumber -= MODULO; |
| 6428 | else if (aNumber < -MODULO / 2) |
| 6429 | aNumber += MODULO; |
| 6430 | return (txInteger)aNumber; |
| 6431 | } |
| 6432 | return 0; |
| 6433 | #else |
| 6434 | int lb = c_ilogb(theValue); |
| 6435 | if ((C_FP_ILOGB0 == lb) || (C_FP_ILOGBNAN == lb)) |
| 6436 | return 0; |
| 6437 | |
| 6438 | if (lb < 31) |
| 6439 | return (txInteger)theValue; |
| 6440 | |
| 6441 | if (C_INT_MAX == lb) |
| 6442 | return 0; |
| 6443 | |
| 6444 | theValue = c_trunc(theValue); |
| 6445 | #define MODULO 4294967296.0 |
| 6446 | theValue = c_fmod(theValue, MODULO); |
| 6447 | if (theValue >= MODULO / 2) |
| 6448 | theValue -= MODULO; |
| 6449 | else if (theValue < -MODULO / 2) |
| 6450 | theValue += MODULO; |
| 6451 | |
| 6452 | return (txInteger)theValue; |
| 6453 | #endif |
| 6454 | } |
| 6455 | |
| 6456 | txString fxNumberToString(void* the, txNumber theValue, txString theBuffer, txSize theSize, txByte theMode, txInteger thePrecision) |
| 6457 | { |
no test coverage detected