3 void prepare_rpn_result_2(calc_number_t
*rpn
, TCHAR
*buffer
, int size
, int base
)
10 _stprintf(buffer
, TEXT("%I64X"), rpn
->i
);
14 * Modifed from 17 to 16 for fixing this bug:
15 * 14+14+6.3+6.3= 40.5999999 instead of 40.6
16 * So, it's probably better to leave the least
17 * significant digit out of the display.
19 #define MAX_LD_WIDTH 16
20 /* calculate the width of integer number */
21 width
= (rpn
->f
==0) ? 1 : (int)log10(fabs(rpn
->f
))+1;
22 if (calc
.sci_out
== TRUE
|| width
> MAX_LD_WIDTH
|| width
< -MAX_LD_WIDTH
)
23 _stprintf(buffer
, TEXT("%#e"), rpn
->f
);
27 ptr
= buffer
+ _stprintf(buffer
, TEXT("%#*.*f"), width
, ((MAX_LD_WIDTH
-width
-1)>=0) ? MAX_LD_WIDTH
-width
-1 : 0, rpn
->f
);
28 /* format sring ensures there is a '.': */
29 dst
= _tcschr(buffer
, TEXT('.'));
31 if (*ptr
!= TEXT('0'))
34 /* put the string terminator for removing the final '0' (if any) */
36 /* check if the number finishes with '.' */
38 /* remove the dot (it will be re-added later) */
44 _stprintf(buffer
, TEXT("%I64o"), rpn
->i
);
48 buffer
[0] = TEXT('0');
49 buffer
[1] = TEXT('\0');
53 buffer
[0] = TEXT('\0');
55 memmove(buffer
+1, buffer
, (size
-1)*sizeof(TCHAR
));
57 calc
.buffer
[0] = TEXT('1');
59 calc
.buffer
[0] = TEXT('0');
66 void convert_text2number_2(calc_number_t
*a
)
72 _stscanf(calc
.buffer
, TEXT("%I64X"), &(a
->i
));
75 _stscanf(calc
.buffer
, TEXT("%lf"), &(a
->f
));
78 _stscanf(calc
.buffer
, TEXT("%I64o"), &(a
->i
));
83 while (*ptr
!= TEXT('\0')) {
85 if (*ptr
++ == TEXT('1'))
92 void convert_real_integer(unsigned int base
)
96 calc
.code
.f
= (double)calc
.code
.i
;
101 if (calc
.base
== IDC_RADIO_DEC
) {
102 calc
.code
.i
= (__int64
)calc
.code
.f
;
103 apply_int_mask(&calc
.code
);