For information about double serialization check rdbSaveDoubleValue() */
| 611 | |
| 612 | /* For information about double serialization check rdbSaveDoubleValue() */ |
| 613 | int rdbLoadDoubleValue(rio *rdb, double *val) { |
| 614 | char buf[256]; |
| 615 | unsigned char len; |
| 616 | |
| 617 | if (rioRead(rdb,&len,1) == 0) return -1; |
| 618 | switch(len) { |
| 619 | case 255: *val = R_NegInf; return 0; |
| 620 | case 254: *val = R_PosInf; return 0; |
| 621 | case 253: *val = R_Nan; return 0; |
| 622 | default: |
| 623 | if (rioRead(rdb,buf,len) == 0) return -1; |
| 624 | buf[len] = '\0'; |
| 625 | if (sscanf(buf, "%lg", val)!=1) return -1; |
| 626 | return 0; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | /* Saves a double for RDB 8 or greater, where IE754 binary64 format is assumed. |
| 631 | * We just make sure the integer is always stored in little endian, otherwise |
no test coverage detected