Skip to content

Commit e0846bb

Browse files
authored
Version 0.1.2
1 parent 78c2f0c commit e0846bb

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

dfloat.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************
2-
* libdfloat, version 0.1.1 Alpha *
2+
* libdfloat, version 0.1.2 Alpha *
33
* Description: Implements floating point numbers *
44
* with exact decimal representations *
55
* Current file: All libdfloat function definitions *
@@ -193,11 +193,14 @@ int dfloat ## big ## _cmp( dfloat ## big ## _t *df1, dfloat ## big ## _t *df2 ){
193193
cpy = (dfloat ## big ## _t *) malloc( sizeof( dfloat ## big ## _t ) );\
194194
dfloat ## big ## _cpy( cpy, df1 );\
195195
dfloat ## big ## _sub( cpy, df2 );\
196-
if( cpy->mantissa > 0 )\
197-
return 1;\
198-
if( cpy->mantissa < 0 )\
199-
return -1;\
200-
return 0;\
196+
if( cpy->mantissa == 0 )\
197+
result = 0;\
198+
else if( cpy->mantissa > 0 )\
199+
result = 1;\
200+
else if( cpy->mantissa < 0 )\
201+
result = -1;\
202+
free( cpy );\
203+
return result;\
201204
}
202205

203206
dfloatN_cmp( 8, 16 )
@@ -267,7 +270,7 @@ char *dfloat ## big ## _ftoa( dfloat ## big ## _t *src ){\
267270
int i;\
268271
int zeros, zeros_end;\
269272
char *buf;\
270-
size1 = ceil( log10( abs( src->mantissa ) ) );\
273+
size1 = (src->mantissa)?ceil( log10( abs( src->mantissa ) ) ):0;\
271274
if( abs( src->mantissa ) == 1 )\
272275
/* Accounts for exact powers of 10 */\
273276
size1++;\

dfloat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************
2-
* libdfloat, version 0.1.1 Alpha *
2+
* libdfloat, version 0.1.2 Alpha *
33
* Description: Implements floating point numbers *
44
* with exact decimal representations *
55
* Current file: Header file for entire project *

0 commit comments

Comments
 (0)