forked from Anobium/Great-Cow-BASIC-Demonstration-Sources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommonLogs_2PlacesPrecision_16F88.gcb
68 lines (55 loc) · 1.8 KB
/
CommonLogs_2PlacesPrecision_16F88.gcb
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
64
65
66
67
68
'''A program for GCGB and GCB.
'''--------------------------------------------------------------------------------------------------------------------------------
'''This program shows common logarithms to two decimal places.
'''
'''
'''@author EvanV based on works of ThomasH
'''@licence GPL
'''@version 1.0a
'''@date 01.04.2015
'''********************************************************************************
; ----- Configuration
#chip 16F88, 8
#config mclr=off ;reset handled internally
#config osc=int ;use internal clock
#include <maths.h>
; ----- Constants
#define LCD_IO 4 ;4-bit mode
#define LCD_RS PortB.2
#define LCD_Enable PortB.3
#define LCD_DB4 PortB.4
#define LCD_DB5 PortB.5
#define LCD_DB6 PortB.6
#define LCD_DB7 PortB.7
#define LCD_NO_RW
; ----- Define Hardware settings
dir PortB out ;all outputs to the LCD
; ----- Variables
dim ii as word
dim outStr, valStr as string
; ----- Main body of program commences here.
for ii = 1 to 65535
cls
print "log10("
print ii ;print argument
print ")="
locate 1,0
print2Places(log10(ii)) ;and its logarithm
wait 2 S
next
; ----- Support methods. Subroutines and Functions
sub print2places(in p2p_arg as word)
;print decently formatted results, to 2 decimal places
valStr = str(p2p_arg)
select case len(valStr)
case 1:
outStr = "0.0" + valStr
case 2:
outStr = "0." + valStr
case 3:
outStr = left(valStr,1) + "." + right(valStr,2)
case 4:
outStr = left(valStr,2) + "." + right(valStr,2)
end select
print outStr
end sub