-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhexconv-test.js
28 lines (23 loc) · 895 Bytes
/
hexconv-test.js
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
var conv = require('./hexconv');
var res;
// 8-bit integers
res = conv.hexToSint("FF"); // -1
process.stdout.write('FF: ' + res + '\n');
res = conv.hexToSint("7F");
process.stdout.write('7F:' + res + '\n');
res = conv.hexToSint("A"); // same as "0A", 10
process.stdout.write('A:' + res + '\n');
// 16-bit integers
res = conv.hexToSint("FFF"); // same as "0FFF", 4095
process.stdout.write('FFF: ' + res + '\n');
res = conv.hexToSint("FFFF"); // -1
process.stdout.write('FFFF: ' + res + '\n');
res = conv.hexToSint("7FFF"); // max int 16
process.stdout.write('7FFF: ' + res + '\n');
// 32-bit integers
res = conv.hexToSint("FFFFFFF"); // same as "0FFF FFFF"
process.stdout.write('FFFFFFF: ' + res + '\n');
res = conv.hexToSint("FFFFFFFF"); // -1
process.stdout.write('FFFFFFFF: ' + res + '\n');
res = conv.hexToSint("7FFFFFFF"); // max int 16
process.stdout.write('7FFFFFFF: ' + res + '\n');