ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
test_fp.c
Go to the documentation of this file.
1#include "../tester.h"
2
3void test_fp_conversion_to_bytes( Environment * _environment, double _value, int _expected[4] ) {
4
5 int result[4];
6
7 cpu_float_single_from_double_to_int_array( _environment, _value, &result[0] );
8
9 if ( memcmp( &_expected[0], &result[0], 4 ) == 0 ) {
10 printf( "." );
11 } else {
12 printf( "\n%f -> %2.2x%2.2x%2.2x%2.2x ... BAD\n", _value, (unsigned char) _expected[0], (unsigned char) _expected[1], (unsigned char) _expected[2], (unsigned char) _expected[3] );
13 printf( " got : %2.2x %2.2x %2.2x %2.2x\n", (unsigned char) result[0], (unsigned char) result[1], (unsigned char) result[2], (unsigned char) result[3] );
14 }
15
16}
17
18void test_fp_conversion_to_double( Environment * _environment, int _value[4], double _expected ) {
19
20 double result;
21
22 cpu_float_single_from_int_array_to_double( _environment, _value, &result );
23
24 if ( ( result - _expected ) < 0.01 ) {
25 printf( "." );
26 } else {
27 printf( "\n%2.2x%2.2x%2.2x%2.2x -> %f ... BAD\n", (unsigned char) _value[0], (unsigned char) _value[1], (unsigned char) _value[2], (unsigned char) _value[3], _expected );
28 printf( " got : %f\n", result );
29 }
30
31}
void cpu_float_single_from_double_to_int_array(Environment *_environment, double _value, int _result[])
Definition 6309.c:6747
void cpu_float_single_from_int_array_to_double(Environment *_environment, int _value[], double *_result)
Definition 6502.c:8709
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.