00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <string.h>
00039 #include <errno.h>
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042
00043 #include "arith.internal.h"
00044
00045
00046 int
00047 AR_convert_str_to_int (AR_DATA *res, const AR_TYPE *resulttype,
00048 int *bits_used, const char *str, const int *base) {
00049
00050 ar_data* result = (ar_data*)res;
00051
00052 ar_data baseval, intval, temp;
00053 AR_TYPE u64type = AR_Int_64_U;
00054 int status = AR_STAT_OK;
00055
00056 if (AR_CLASS(*resulttype) != AR_CLASS_INT ||
00057 AR_INT_SIZE(*resulttype) == AR_INT_SIZE_128 ||
00058 AR_SIGNEDNESS(*resulttype) != AR_UNSIGNED)
00059 return AR_STAT_INVALID_TYPE;
00060
00061 ZERO_INT64(result);
00062 ZERO_INT16_UPPER(&baseval);
00063
00064 switch (*base) {
00065 case 2:
00066 case 8:
00067 case 10:
00068 case 16:
00069 baseval.ar_i64.part4 = *base;
00070 break;
00071 default:
00072 return AR_STAT_UNDEFINED;
00073 }
00074
00075 ZERO_INT64(&intval);
00076
00077
00078 if (*str) {
00079 if (*str >= '0' && *str <= '9')
00080 if (*base > (*str-'0'))
00081 result->ar_i64.part4 = *str - '0';
00082 else
00083 return AR_STAT_UNDEFINED;
00084 else if (*base != 16)
00085 return AR_STAT_UNDEFINED;
00086 else if (*str >= 'A' && *str <= 'F')
00087 result->ar_i64.part4 = *str - 'A' + 10;
00088 else if (*str >= 'a' && *str <= 'f')
00089 result->ar_i64.part4 = *str - 'a' + 10;
00090 else
00091 return AR_STAT_UNDEFINED;
00092 str++;
00093 }
00094
00095 for (; *str; str++) {
00096 if (*str >= '0' && *str <= '9')
00097 if (*base > (*str-'0'))
00098 intval.ar_i64.part4 = *str - '0';
00099 else
00100 return AR_STAT_UNDEFINED;
00101 else if (*base != 16)
00102 return AR_STAT_UNDEFINED;
00103 else if (*str >= 'A' && *str <= 'F')
00104 intval.ar_i64.part4 = *str - 'A' + 10;
00105 else if (*str >= 'a' && *str <= 'f')
00106 intval.ar_i64.part4 = *str - 'a' + 10;
00107 else
00108 return AR_STAT_UNDEFINED;
00109 status |= ar_multiply_integer (&temp, &u64type,
00110 result, &u64type,
00111 &baseval, &u64type);
00112 status |= ar_add_integer (result, &u64type,
00113 &temp, &u64type,
00114 &intval, &u64type);
00115 }
00116
00117 if (status & (AR_STAT_UNDEFINED | AR_STAT_INVALID_TYPE))
00118 ar_internal_error (2002, __FILE__, __LINE__);
00119
00120
00121
00122 switch(AR_INT_SIZE(*resulttype)) {
00123 case AR_INT_SIZE_8:
00124 if(!IS_INT8_UPPER_ZERO(result))
00125 status |= AR_STAT_OVERFLOW;
00126 break;
00127
00128 case AR_INT_SIZE_16:
00129 if(!IS_INT16_UPPER_ZERO(result))
00130 status |= AR_STAT_OVERFLOW;
00131 break;
00132
00133 case AR_INT_SIZE_24:
00134 if(!IS_INT24_UPPER_ZERO(result))
00135 status |= AR_STAT_OVERFLOW;
00136 break;
00137
00138 case AR_INT_SIZE_32:
00139 if(!IS_INT32_UPPER_ZERO(result))
00140 status |= AR_STAT_OVERFLOW;
00141 break;
00142
00143 case AR_INT_SIZE_46:
00144 if(!IS_INT46_UPPER_ZERO(result))
00145 status |= AR_STAT_OVERFLOW;
00146 break;
00147 }
00148
00149
00150 status &= AR_STAT_OVERFLOW;
00151
00152 if(status)
00153 ar_set_invalid_result(result, resulttype);
00154 else
00155 ar_clear_unused_bits(result, resulttype);
00156
00157 if (bits_used) {
00158 AR_leadz ((AR_DATA*)&temp, &u64type, (AR_DATA*)result,
00159 &u64type);
00160 *bits_used = 64 - temp.ar_i64.part4;
00161 }
00162
00163 switch(AR_INT_SIZE(*resulttype)) {
00164 case AR_INT_SIZE_8:
00165 if (IS_INT8_ZERO(result))
00166 status |= AR_STAT_ZERO;
00167 break;
00168
00169 case AR_INT_SIZE_16:
00170 if (IS_INT16_ZERO(result))
00171 status |= AR_STAT_ZERO;
00172 break;
00173
00174 case AR_INT_SIZE_24:
00175 if (IS_INT24_ZERO(result))
00176 status |= AR_STAT_ZERO;
00177 break;
00178
00179 case AR_INT_SIZE_32:
00180 if (IS_INT32_ZERO(result))
00181 status |= AR_STAT_ZERO;
00182 break;
00183
00184 case AR_INT_SIZE_46:
00185 if (IS_INT46_ZERO(result))
00186 status |= AR_STAT_ZERO;
00187 break;
00188
00189 case AR_INT_SIZE_64:
00190 if (IS_INT64_ZERO(result))
00191 status |= AR_STAT_ZERO;
00192 break;
00193 }
00194
00195 return status;
00196 }
00197
00198
00199
00200 int
00201 AR_convert_int_to_str (char *resultstr, const int *base,
00202 const AR_DATA *opd, const AR_TYPE *opndtype) {
00203
00204 ar_data* opnd = (ar_data*)opd;
00205
00206 ar_data baseval, intval, divresult, modresult;
00207 AR_TYPE intvaltype;
00208 int i, isnegative, status;
00209 char str [66];
00210
00211 if (AR_CLASS (*opndtype) != AR_CLASS_INT)
00212 return AR_STAT_INVALID_TYPE;
00213
00214
00215 if (*base == 10 && AR_SIGNEDNESS (*opndtype) == AR_SIGNED)
00216 intvaltype = AR_Int_64_S;
00217 else
00218 intvaltype = AR_Int_64_U;
00219 ar_convert_to_integral (&intval, &intvaltype, opnd, opndtype);
00220
00221 ZERO_INT16_UPPER(&baseval);
00222
00223 switch (*base) {
00224 case 2:
00225 case 8:
00226 case 10:
00227 case 16:
00228 baseval.ar_i64.part4 = *base;
00229 break;
00230 default:
00231 return AR_STAT_UNDEFINED;
00232 }
00233
00234 if (*base == 10 &&
00235 AR_SIGNEDNESS (intvaltype) == AR_SIGNED &&
00236 INT64_SIGN(&intval)) {
00237 isnegative = 1;
00238 intvaltype = AR_Int_64_U;
00239 ar_negate_integer (&intval, &intvaltype, &intval, &intvaltype);
00240 } else
00241 isnegative = 0;
00242
00243 i = sizeof (str);
00244 str [--i] = '\0';
00245
00246 do {
00247 status = ar_divide_integer (&divresult, &intvaltype,
00248 &modresult, &intvaltype,
00249 &intval, &intvaltype,
00250 &baseval, &intvaltype);
00251 if (status & (AR_STAT_UNDEFINED | AR_STAT_INVALID_TYPE))
00252 ar_internal_error (2003, __FILE__, __LINE__);
00253 str [--i] = modresult.ar_i64.part4 + '0';
00254 intval = divresult;
00255 } while (!IS_INT64_ZERO(&intval));
00256
00257 if (isnegative)
00258 str [--i] = '-';
00259
00260 strcpy (resultstr, str + i);
00261
00262 return AR_STAT_OK;
00263 }
00264
00265
00266 int
00267 ar_cvt_str_to_float (ar_data *result, const AR_TYPE *resulttype,
00268 const char *str)
00269 {
00270 int status = AR_STAT_OK;
00271 char *endptr;
00272
00273 #if _CRAY
00274
00275
00276
00277
00278
00279 errno = 0;
00280
00281 switch(AR_FLOAT_SIZE(*resulttype)) {
00282
00283 case AR_FLOAT_64:
00284 *((double*)result) = strtod (str, &endptr);
00285 break;
00286
00287 case AR_FLOAT_128:
00288 *((long double*)result) = strtold (str, &endptr);
00289 break;
00290
00291 default:
00292 return AR_STAT_INVALID_TYPE;
00293 }
00294
00295 #elif _Solaris
00296
00297
00298
00299 #define MODESP 000
00300 #define MODEDP 004
00301 #define MODEHP 020
00302
00303
00304
00305 #define EX_REAL64 3
00306 #define EX_REAL128 4
00307 #define EX_REAL32 5
00308 #define EX_ILLCHAR -1
00309 #define EX_EXPUFLO -3
00310 #define EX_EXPOFLO -4
00311 #define EX_NULLFLD -5
00312
00313 long fw, d, p;
00314
00315 long* lcap1;
00316 long mode;
00317 long stat;
00318
00319 long ichars[64];
00320
00321
00322
00323 status = ar_unpack_float_str(ichars, 64, &fw, &d, &p, str);
00324 if (IS_ERROR_STATUS(status))
00325 return status;
00326
00327 switch(AR_FLOAT_SIZE(*resulttype)) {
00328 case AR_FLOAT_32:
00329 ZEROIEEE32 (result->ar_ieee32);
00330 mode = MODEHP;
00331 break;
00332 case AR_FLOAT_64:
00333 ZEROIEEE64 (result->ar_ieee64);
00334 mode = MODESP;
00335 break;
00336 case AR_FLOAT_128:
00337 ZEROIEEE128 (result->ar_ieee128);
00338 mode = MODEDP;
00339 break;
00340 }
00341
00342 if(status == AR_STAT_ZERO)
00343 return AR_STAT_ZERO;
00344
00345 lcap1 = &ichars[fw];
00346 _defgu2sd(ichars, &fw, &lcap1, &mode, result, &stat, &d, &p);
00347
00348
00349
00350
00351
00352
00353 switch (stat) {
00354 case EX_REAL32:
00355 result[0].ar_i64.part3 = result[0].ar_i64.part1;
00356 result[0].ar_i64.part4 = result[0].ar_i64.part2;
00357 result[0].ar_i64.part1 = result[0].ar_i64.part2 = 0;
00358 case EX_REAL64:
00359 case EX_REAL128:
00360 status = AR_status((AR_DATA*)result, resulttype);
00361 break;
00362
00363 case EX_EXPUFLO:
00364 switch(AR_FLOAT_SIZE(*resulttype)) {
00365 case AR_FLOAT_32:
00366 ZEROIEEE32 (result->ar_ieee32);
00367 break;
00368 case AR_FLOAT_64:
00369 ZEROIEEE64 (result->ar_ieee64);
00370 break;
00371 case AR_FLOAT_128:
00372 ZEROIEEE128 (result->ar_ieee128);
00373 break;
00374 }
00375 status = AR_STAT_UNDERFLOW|AR_STAT_ZERO;
00376 break;
00377 case EX_EXPOFLO:
00378 status = AR_STAT_OVERFLOW;
00379 break;
00380 default:
00381 status = AR_STAT_UNDEFINED;
00382 break;
00383 }
00384
00385 return status;
00386
00387 #elif defined(__mips)
00388
00389 ar_data dval;
00390 double d;
00391 long double ld;
00392 AR_TYPE float_64 = ((AR_TYPE) UNROUNDED_TYPE(AR_Float_IEEE_NR_64));
00393
00394
00395 extern double strtod(const char *, char **);
00396 extern long double strtold(const char *, char **);
00397
00398 errno = 0;
00399
00400 switch(AR_FLOAT_SIZE(*resulttype)) {
00401
00402 case AR_FLOAT_32:
00403 d = strtod (str, &endptr);
00404 status = AR_convert((AR_DATA*)result, resulttype,
00405 (AR_DATA*)&d, &float_64);
00406 break;
00407
00408 case AR_FLOAT_64:
00409 d = strtod (str, &endptr);
00410 memcpy(result,&d,sizeof(double));
00411 break;
00412
00413 case AR_FLOAT_128:
00414 ld = strtold (str, &endptr);
00415 memcpy(result,&ld,sizeof(long double));
00416 break;
00417 }
00418
00419 if (IS_ERROR_STATUS(status))
00420 return status;
00421
00422 #else
00423
00424 ar_data dval;
00425 AR_TYPE float_64 = UNROUNDED_TYPE(AR_Float_IEEE_NR_64);
00426
00427
00428 extern double strtod(const char *, char **);
00429
00430 errno = 0;
00431
00432 switch(AR_FLOAT_SIZE(*resulttype)) {
00433
00434 case AR_FLOAT_32:
00435 *(double*)(&dval) = strtod (str, &endptr);
00436 status = AR_convert((AR_DATA*)result, resulttype,
00437 (AR_DATA*)&dval, &float_64);
00438 break;
00439
00440 case AR_FLOAT_64:
00441 *((double*)result) = strtod (str, &endptr);
00442 break;
00443
00444 case AR_FLOAT_128:
00445 *(double*)(&dval) = strtod (str, &endptr);
00446 status = AR_convert((AR_DATA*)result, resulttype,
00447 (AR_DATA*)&dval, &float_64);
00448 break;
00449 }
00450
00451 if (IS_ERROR_STATUS(status))
00452 return status;
00453 #endif
00454
00455 if (*endptr)
00456
00457 return AR_STAT_UNDEFINED;
00458
00459 if (errno == ERANGE)
00460 return AR_STAT_OVERFLOW;
00461
00462 return AR_status((AR_DATA*)result, resulttype) |
00463 (status & AR_STAT_UNDERFLOW);
00464 }
00465
00466 int
00467 ar_unpack_float_str(long* ibuf, long maxbuflen, long* w, long* d, long *p,
00468 const char *str)
00469 {
00470 int i;
00471 int n;
00472 int t;
00473 int x;
00474 int z;
00475
00476 *w = 0;
00477 *d = 0;
00478 *p = 0;
00479 i = 0;
00480
00481
00482 while (*str == ' ' ||
00483 *str == '\f' ||
00484 *str == '\n' ||
00485 *str == '\r' ||
00486 *str == '\t' ||
00487 *str == '\v')
00488 str++;
00489 if (*str == '+' || *str == '-')
00490 ibuf[i++] = *str++;
00491
00492
00493 if(*str == '0') {
00494 z = 1;
00495 while(*(++str) == '0')
00496 ;
00497 }
00498 else
00499 z = -1;
00500
00501
00502 if (*str >= '0' && *str <= '9'){
00503 z = 0;
00504 ibuf[i++] = *str++;
00505 while (*str >= '0' && *str <= '9'){
00506 if (i < (maxbuflen-6))
00507 ibuf[i++] = *str++;
00508 else {
00509
00510
00511
00512
00513 (*p)--;
00514 str++;
00515 }
00516 }
00517 }
00518
00519
00520
00521
00522 if (*str == '.') {
00523
00524 if (i == (maxbuflen-6)) i--;
00525 ibuf[i++] = *str++;
00526 if(z == 1) {
00527 while (*str == '0') {
00528 (*p)++;
00529 str++;
00530 }
00531 }
00532 while (*str >= '0' && *str <= '9') {
00533 if (i < (maxbuflen-6))
00534 ibuf[i++] = *str;
00535 str++;
00536 (*d)++;
00537 z = 0;
00538 }
00539 }
00540
00541 if (z == -1)
00542 return AR_STAT_UNDEFINED;
00543
00544 if (z == 1) {
00545 ibuf[i++] = '0';
00546 *p = 0;
00547 *w = i;
00548 if(ibuf[0] == '-')
00549 return AR_STAT_NEGATIVE | AR_STAT_ZERO;
00550 else
00551 return AR_STAT_ZERO;
00552 }
00553
00554
00555 if (*str == 'e' || *str == 'E') {
00556 ibuf[i++] = 'E';
00557 str++;
00558 if(*p) {
00559
00560 x = atoi(str)-*p;
00561 if(x < 0) {
00562 ibuf[i++] = '-';
00563 x = -x;
00564 }
00565 if (x < 10) t=1;
00566 else if (x < 100) t=10;
00567 else if (x < 1000) t=100;
00568 else t=1000;
00569 while(t > 1) {
00570
00571
00572
00573 n = x/t;
00574 x -= (n*t);
00575 t = (t+1)/10;
00576 ibuf[i++] = '0'+n;
00577 }
00578 ibuf[i++] = '0'+x;
00579 if (*str == '+' || *str == '-')
00580 str++;
00581 while (*str >= '0' && *str <= '9')
00582 str++;
00583 *p = 0;
00584 }
00585 else {
00586 if (*str == '+' || *str == '-')
00587 ibuf[i++] = *str++;
00588 while (*str=='0')
00589 str++;
00590 while (*str >= '0' && *str <= '9') {
00591 if (i == maxbuflen) break;
00592 ibuf[i++] = *str++;
00593 }
00594 if ((ibuf[i-1] < '0' || ibuf[i-1] > '9')
00595 && *(str-1)=='0')
00596 ibuf[i++] = '0';
00597 }
00598 }
00599
00600 if(*str != '\0')
00601 return AR_STAT_UNDEFINED;
00602
00603 *w = i;
00604
00605 return AR_STAT_OK;
00606 }
00607
00608
00609
00610 int
00611 AR_convert_float_to_str (char *resultstr,
00612 const AR_DATA *opd, const AR_TYPE *opndtype) {
00613
00614 ar_data* opnd = (ar_data*)opd;
00615
00616 ar_data temp, temp2;
00617 AR_TYPE temptype;
00618 int status = AR_STAT_OK;
00619
00620 #if defined _CRAY && !defined _CRAYMPP
00621
00622 switch (*opndtype) {
00623 case AR_Float_Cray1_64:
00624 case AR_Float_Cray1_64_F:
00625 sprintf (resultstr, "%.14e", opnd->ar_f64);
00626 break;
00627 case AR_Float_Cray1_128:
00628 sprintf (resultstr, "%.27Le", opnd->ar_f128);
00629 break;
00630 case AR_Float_IEEE_NR_32:
00631 case AR_Float_IEEE_ZE_32:
00632 case AR_Float_IEEE_UP_32:
00633 case AR_Float_IEEE_DN_32:
00634 status = AR_status(opd, opndtype);
00635 if (status & AR_STAT_OVERFLOW)
00636 sprintf(resultstr, "%sInf",
00637 (status & AR_STAT_NEGATIVE) ? "-" : "+");
00638 else if (status & AR_STAT_ZERO)
00639 sprintf(resultstr, "%s%.7e",
00640 (status & AR_STAT_NEGATIVE) ? "-" : "", 0.0);
00641 else if (status & AR_STAT_UNDEFINED)
00642 strcpy(resultstr, "NaN");
00643 else if (HOST_IS_IEEE_FLOAT) {
00644 status = ar_i32to64 (&temp2.ar_ieee64,
00645 &opnd->ar_ieee32);
00646 sprintf (resultstr, "%.7e",
00647 (*(double *) &temp2.ar_ieee64));
00648 }
00649 else {
00650 status = ar_i32to64 (&temp2.ar_ieee64,
00651 &opnd->ar_ieee32);
00652 status |= ar_i64toc128 (&temp.ar_f128,
00653 &temp2.ar_ieee64);
00654 sprintf (resultstr, "%.16Le", temp.ar_f128);
00655 }
00656 break;
00657 case AR_Float_IEEE_NR_64:
00658 case AR_Float_IEEE_ZE_64:
00659 case AR_Float_IEEE_UP_64:
00660 case AR_Float_IEEE_DN_64:
00661 status = AR_status(opd, opndtype);
00662 if (status & AR_STAT_OVERFLOW)
00663 sprintf(resultstr, "%sInf",
00664 (status & AR_STAT_NEGATIVE) ? "-" : "+");
00665 else if (status & AR_STAT_ZERO)
00666 sprintf(resultstr, "%s%.16e",
00667 (status & AR_STAT_NEGATIVE) ? "-" : "", 0.0);
00668 else if (status & AR_STAT_UNDEFINED)
00669 strcpy(resultstr, "NaN");
00670 else if (HOST_IS_IEEE_FLOAT) {
00671 sprintf (resultstr, "%.16e",
00672 (*(double *) &opnd->ar_ieee64));
00673 }
00674 else
00675 {
00676 status = ar_i64toc128 (&temp.ar_f128,
00677 &opnd->ar_ieee64);
00678 sprintf (resultstr, "%.16Le", temp.ar_f128);
00679 }
00680 break;
00681 case AR_Float_IEEE_NR_128:
00682 case AR_Float_IEEE_ZE_128:
00683 case AR_Float_IEEE_UP_128:
00684 case AR_Float_IEEE_DN_128:
00685 status = AR_status(opd, opndtype);
00686 if (status & AR_STAT_OVERFLOW)
00687 sprintf(resultstr, "%sInf",
00688 (status & AR_STAT_NEGATIVE) ? "-" : "+");
00689 else if (status & AR_STAT_ZERO)
00690 sprintf(resultstr, "%s%.34e",
00691 (status & AR_STAT_NEGATIVE) ? "-" : "", 0.0);
00692 else if (status & AR_STAT_UNDEFINED)
00693 strcpy(resultstr, "NaN");
00694 else if (HOST_IS_IEEE_FLOAT) {
00695 sprintf (resultstr, "%.34Le",
00696 (*(long double *) &opnd->ar_ieee128));
00697 }
00698 else
00699 {
00700 status = ar_itoc128 (&temp.ar_f128, &opnd->ar_ieee128,
00701 ar_state_register.ar_rounding_mode);
00702 sprintf (resultstr, "%.34Le", temp.ar_f128);
00703 }
00704 break;
00705 default:
00706 return AR_STAT_INVALID_TYPE;
00707 }
00708
00709 return status;
00710
00711 #else
00712
00713 switch (*opndtype) {
00714 case AR_Float_Cray1_64:
00715 case AR_Float_Cray1_64_F:
00716 status |= ar_ctoi64 (&temp.ar_ieee64, &opnd->ar_f64);
00717 sprintf (resultstr, "%.15e", *((double *) &temp.ar_ieee64));
00718 break;
00719 case AR_Float_Cray1_128:
00720 status |= ar_ctoi64 (&temp.ar_ieee64, &opnd->ar_f64);
00721 sprintf (resultstr, "%.29e", *((double *) &temp.ar_ieee64));
00722 break;
00723 case AR_Float_IEEE_NR_32:
00724 case AR_Float_IEEE_ZE_32:
00725 case AR_Float_IEEE_UP_32:
00726 case AR_Float_IEEE_DN_32:
00727 status |= ar_i32to64 (&temp.ar_ieee64, &opnd->ar_ieee32);
00728 sprintf(resultstr, "%.7e", *((double *) &temp.ar_ieee64));
00729 break;
00730 case AR_Float_IEEE_NR_64:
00731 case AR_Float_IEEE_ZE_64:
00732 case AR_Float_IEEE_UP_64:
00733 case AR_Float_IEEE_DN_64:
00734 sprintf(resultstr, "%.16le", *((double*) &opnd->ar_ieee64));
00735 break;
00736 case AR_Float_IEEE_NR_128:
00737 case AR_Float_IEEE_ZE_128:
00738 case AR_Float_IEEE_UP_128:
00739 case AR_Float_IEEE_DN_128:
00740
00741 status |= ar_i128to64 (&temp.ar_ieee64, &opnd->ar_ieee128,
00742 AR_ROUND_NEAREST);
00743 sprintf(resultstr, "%.34le", *((double*) &temp.ar_ieee64));
00744 break;
00745 default:
00746 return AR_STAT_INVALID_TYPE;
00747 }
00748
00749 return status;
00750
00751 #endif
00752
00753 }
00754
00755
00756
00757 int
00758 AR_convert_hex_str_to_float (AR_DATA *result, const AR_TYPE *resulttype,
00759 const char *str) {
00760
00761
00762 int status = AR_STAT_OK;
00763 AR_DATA temp;
00764 const int base = 16;
00765 int bitsused;
00766 const AR_TYPE result64 = AR_Int_64_U;
00767 char save_char;
00768 char temp_string[17];
00769
00770 errno = 0;
00771
00772 switch (*resulttype) {
00773 case AR_Float_Cray1_64:
00774 case AR_Float_Cray1_64_F:
00775 case AR_Float_IEEE_NR_32:
00776 case AR_Float_IEEE_ZE_32:
00777 case AR_Float_IEEE_UP_32:
00778 case AR_Float_IEEE_DN_32:
00779 case AR_Float_IEEE_NR_64:
00780 case AR_Float_IEEE_ZE_64:
00781 case AR_Float_IEEE_UP_64:
00782 case AR_Float_IEEE_DN_64:
00783 status = AR_convert_str_to_int(result, &result64, &bitsused,
00784 str, &base);
00785 break;
00786
00787 case AR_Float_IEEE_NR_128:
00788 case AR_Float_IEEE_ZE_128:
00789 case AR_Float_IEEE_UP_128:
00790 case AR_Float_IEEE_DN_128:
00791 case AR_Float_Cray1_128:
00792 strncpy(temp_string, str, 16);
00793 temp_string[16] = '\0';
00794 status = AR_convert_str_to_int(result, &result64, &bitsused,
00795 temp_string, &base);
00796 status |= AR_convert_str_to_int(&temp, &result64, &bitsused,
00797 str+16, &base);
00798
00799 result->ar_internal_data_item2 = temp.ar_internal_data_item1;
00800
00801 break;
00802
00803 default:
00804 return AR_STAT_INVALID_TYPE;
00805 }
00806
00807
00808 return (status & AR_STAT_UNDEFINED);
00809 }
00810
00811
00812 int
00813 AR_convert_host_sint64_to_int(AR_DATA *result, const AR_TYPE *resulttype,
00814 AR_HOST_SINT64 i64val)
00815 {
00816
00817 AR_TYPE s64type = AR_Int_64_S;
00818
00819 if (AR_CLASS(*resulttype) != AR_CLASS_INT)
00820 return AR_STAT_INVALID_TYPE;
00821
00822 result->ar_internal_data_item1 = i64val;
00823
00824 return (AR_convert(result, resulttype, result, &s64type));
00825 }
00826
00827
00828 int
00829 AR_convert_int_to_host_sint64(AR_HOST_SINT64 *i64val,
00830 const AR_DATA *opnd, const AR_TYPE *opndtype)
00831 {
00832 int status;
00833 AR_TYPE s64type = AR_Int_64_S;
00834 AR_DATA s64val;
00835
00836 if (AR_CLASS(*opndtype) != AR_CLASS_INT)
00837 return AR_STAT_INVALID_TYPE;
00838
00839 status = AR_convert(&s64val, &s64type, opnd, opndtype);
00840
00841 *i64val = s64val.ar_internal_data_item1;
00842
00843 return (status);
00844 }
00845
00846
00847 static char USMID [] = "\n%Z%%M% %I% %G% %U%\n";
00848 static char rcsid [] = "$Id: strcvt.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $";