ReactOS 0.4.15-dev-7842-g558ab78
utl_ieee.c File Reference
#include "calc.h"
Include dependency graph for utl_ieee.c:

Go to the source code of this file.

Macros

#define MAX_LD_WIDTH   16
 

Functions

void prepare_rpn_result_2 (calc_number_t *rpn, TCHAR *buffer, int size, int base)
 
void convert_text2number_2 (calc_number_t *a)
 
void convert_real_integer (unsigned int base)
 

Macro Definition Documentation

◆ MAX_LD_WIDTH

#define MAX_LD_WIDTH   16

Function Documentation

◆ convert_real_integer()

void convert_real_integer ( unsigned int  base)

Definition at line 112 of file utl_ieee.c.

113{
114 switch (base) {
115 case IDC_RADIO_DEC:
117 break;
118 case IDC_RADIO_OCT:
119 case IDC_RADIO_BIN:
120 case IDC_RADIO_HEX:
124 }
125 break;
126 }
127}
#define IDC_RADIO_BIN
Definition: resource.h:26
#define IDC_RADIO_OCT
Definition: resource.h:25
#define IDC_RADIO_DEC
Definition: resource.h:24
#define IDC_RADIO_HEX
Definition: resource.h:23
#define __int64
Definition: basetyps.h:16
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26
calc_t calc
Definition: winmain.c:247
if(dx< 0)
Definition: linetemp.h:194
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
calc_number_t code
Definition: calc.h:178
DWORD base
Definition: calc.h:189
INT64 i
Definition: calc.h:127
double f
Definition: calc.h:126

◆ convert_text2number_2()

void convert_text2number_2 ( calc_number_t a)

Definition at line 86 of file utl_ieee.c.

87{
88 TCHAR *ptr;
89
90 switch (calc.base) {
91 case IDC_RADIO_HEX:
92 _stscanf(calc.buffer, _T("%I64X"), &(a->i));
93 break;
94 case IDC_RADIO_DEC:
95 _stscanf(calc.buffer, _T("%lf"), &(a->f));
96 break;
97 case IDC_RADIO_OCT:
98 _stscanf(calc.buffer, _T("%I64o"), &(a->i));
99 break;
100 case IDC_RADIO_BIN:
101 ptr = calc.buffer;
102 a->i = 0;
103 while (*ptr != _T('\0')) {
104 a->i <<= 1;
105 if (*ptr++ == _T('1'))
106 a->i |= 1;
107 }
108 break;
109 }
110}
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define _stscanf
Definition: tchar.h:557
static PVOID ptr
Definition: dispmode.c:27
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:175
#define _T(x)
Definition: vfdio.h:22
char TCHAR
Definition: xmlstorage.h:189

◆ prepare_rpn_result_2()

void prepare_rpn_result_2 ( calc_number_t rpn,
TCHAR buffer,
int  size,
int  base 
)

Definition at line 23 of file utl_ieee.c.

24{
25 calc_number_t tmp;
26 int width;
27
28 switch (base) {
29 case IDC_RADIO_HEX:
30 StringCchPrintf(buffer, size, _T("%I64X"), rpn->i);
31 break;
32 case IDC_RADIO_DEC:
33/*
34 * Modified from 17 to 16 for fixing this bug:
35 * 14+14+6.3+6.3= 40.5999999 instead of 40.6
36 * So, it's probably better to leave the least
37 * significant digit out of the display.
38 */
39#define MAX_LD_WIDTH 16
40 /* calculate the width of integer number */
41 width = (rpn->f==0) ? 1 : (int)log10(fabs(rpn->f))+1;
43 StringCchPrintf(buffer, size, _T("%#.*e"), MAX_LD_WIDTH-1, rpn->f);
44 else {
45 TCHAR *ptr, *dst;
46
47 StringCchPrintfEx(buffer, size, &ptr, NULL, 0, _T("%#*.*f"), width, ((MAX_LD_WIDTH-width-1)>=0) ? MAX_LD_WIDTH-width-1 : 0, rpn->f);
48 /* format string ensures there is a '.': */
49 dst = _tcschr(buffer, _T('.'));
50 while (--ptr > dst)
51 if (*ptr != _T('0'))
52 break;
53
54 /* put the string terminator for removing the final '0' (if any) */
55 ptr[1] = _T('\0');
56 /* check if the number finishes with '.' */
57 if (ptr == dst)
58 /* remove the dot (it will be re-added later) */
59 ptr[0] = _T('\0');
60 }
61#undef MAX_LD_WIDTH
62 break;
63 case IDC_RADIO_OCT:
64 StringCchPrintf(buffer, size, _T("%I64o"), rpn->i);
65 break;
66 case IDC_RADIO_BIN:
67 if (rpn->i == 0) {
68 buffer[0] = _T('0');
69 buffer[1] = _T('\0');
70 break;
71 }
72 tmp = *rpn;
73 buffer[0] = _T('\0');
74 while (tmp.u) {
75 memmove(buffer+1, buffer, (size-1)*sizeof(TCHAR));
76 if (tmp.u & 1)
77 buffer[0] = _T('1');
78 else
79 buffer[0] = _T('0');
80 tmp.u >>= 1;
81 }
82 break;
83 }
84}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
double log10(double x)
Definition: freeldr.c:124
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLenum dst
Definition: glext.h:6340
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
Definition: fabs.c:17
#define _tcschr
Definition: tchar.h:1406
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define StringCchPrintf
Definition: strsafe.h:517
#define StringCchPrintfEx
Definition: strsafe.h:572
BOOL sci_out
Definition: calc.h:184
UINT64 u
Definition: calc.h:128
#define MAX_LD_WIDTH