ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
suite_fp.c
Go to the documentation of this file.
1#include "../tester.h"
2
3int suite_fp( Environment * _environment ) {
4
5 printf( "==== FLOATING POINT SUPPORT (COMPILE TIME) ====\n" );
6
7 printf( "--- FLOAT <-> BYTES conversion\n" );
8
9 double values[] = { 10.0, 1.0, 0.1, 0.0, /*-0.1,*/ -1.0, -10.0, -0.3 };
10
11 int expected[][4] = {
12 // 10.0
13 {
14 0x83, 0x50, 0x00, 0x00
15 },
16 // 1.0
17 {
18 0x80, 0x40, 0x00, 0x00
19 },
20 // 0.1
21 {
22 0x7C, 0x66, 0x66, 0x66
23 },
24 // 0.0
25 {
26 0x00, 0x00, 0x00, 0x00
27 },
28 // // -0.1
29 // {
30 // 0xFC, 0x99, 0x99, 0x9A
31 // },
32 // -1.0
33 {
34 0x7F, 0x80, 0x00, 0x00
35 },
36 // -10.0
37 {
38 0x83, 0xB0, 0x00, 0x00
39 },
40 // -0.3
41 {
42 0x00, 0x00, 0x00, 0x00
43 }
44 };
45
46 for( int i=0; i<( sizeof( values ) / sizeof( double ) )-1; ++i ) {
47 test_fp_conversion_to_bytes( _environment, values[i], &expected[i][0] );
48 test_fp_conversion_to_double( _environment, &expected[i][0], values[i] );
49 }
50
51 printf( "\n" );
52
53}
int suite_fp(Environment *_environment)
Definition suite_fp.c:3
void test_fp_conversion_to_double(Environment *_environment, int _value[4], double _expected)
Definition test_fp.c:18
void test_fp_conversion_to_bytes(Environment *_environment, double _value, int _expected[4])
Definition test_fp.c:3
struct _Environment Environment
Structure of compilation environment.