-
Notifications
You must be signed in to change notification settings - Fork 1
/
print.c
63 lines (46 loc) · 1.46 KB
/
print.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* =====[ print.c ]=========================================================
Description: Printer routines for pcalc.
Revisions:
REV DATE BY DESCRIPTION
---- -------- ---------- --------------------------------------
0.00 mm/dd/95 Peter Glen Initial version.
1.00 22/9/98 Peter Glen Unix port
======================================================================= */
/* -------- System includes: -------------------------------------------- */
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
/* -------- Includes: --------------------------------------------------- */
#include "convert.h"
#include "hocdecl.h"
#include "symbol.h"
/* -------- Implementation: ---------------------------------------------- */
static char work_str[128];
void print_num(double var)
{
Symbol *msx = lookup_sym("DEC");
// compatibility variable:
if(!msx)
msx = lookup_sym("DECIMAL");
if(msx && msx->u.val == 1)
{
printf("%g" , var);
}
else if(msx && msx->u.val == 2)
{
printf("%llx" , (unsigned long long)var);
}
else if(msx && msx->u.val == 3)
{
long_to_bin_str((unsigned long long)var, work_str);
printf("%s", work_str);
}
else
{
long_to_bin_str((unsigned long long)var, work_str);
printf("\t%-16.16g\t0x%-16llx\t0y%s\n" , var, (unsigned long long)var, work_str);
}
}
/* EOF */