| 1382 | |
| 1383 | |
| 1384 | double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, bool* getNumericOverflow) |
| 1385 | { |
| 1386 | /************************************** |
| 1387 | * |
| 1388 | * C V T _ g e t _ d o u b l e |
| 1389 | * |
| 1390 | ************************************** |
| 1391 | * |
| 1392 | * Functional description |
| 1393 | * Convert something arbitrary to a double precision number |
| 1394 | * |
| 1395 | **************************************/ |
| 1396 | double value; |
| 1397 | |
| 1398 | switch (desc->dsc_dtype) |
| 1399 | { |
| 1400 | case dtype_short: |
| 1401 | value = *((SSHORT *) desc->dsc_address); |
| 1402 | break; |
| 1403 | |
| 1404 | case dtype_long: |
| 1405 | value = *((SLONG *) desc->dsc_address); |
| 1406 | break; |
| 1407 | |
| 1408 | case dtype_quad: |
| 1409 | value = ((SLONG *) desc->dsc_address)[HIGH_WORD]; |
| 1410 | value *= -((double) LONG_MIN_real); |
| 1411 | if (value < 0) |
| 1412 | value -= ((ULONG *) desc->dsc_address)[LOW_WORD]; |
| 1413 | else |
| 1414 | value += ((ULONG *) desc->dsc_address)[LOW_WORD]; |
| 1415 | break; |
| 1416 | |
| 1417 | case dtype_int64: |
| 1418 | value = (double) *((SINT64 *) desc->dsc_address); |
| 1419 | break; |
| 1420 | |
| 1421 | case dtype_real: |
| 1422 | return *((float*) desc->dsc_address); |
| 1423 | |
| 1424 | case DEFAULT_DOUBLE: |
| 1425 | // memcpy is done in case dsc_address is on a platform dependant |
| 1426 | // invalid alignment address for doubles |
| 1427 | memcpy(&value, desc->dsc_address, sizeof(double)); |
| 1428 | return value; |
| 1429 | |
| 1430 | case dtype_dec64: |
| 1431 | case dtype_dec128: |
| 1432 | { |
| 1433 | Decimal128 d128; |
| 1434 | if (desc->dsc_dtype == dtype_dec64) |
| 1435 | d128 = *((Decimal64*) desc->dsc_address); |
| 1436 | else |
| 1437 | d128 = *((Decimal128*) desc->dsc_address); |
| 1438 | |
| 1439 | return d128.toDouble(decSt); |
| 1440 | } |
| 1441 |
no test coverage detected