#185 extern_float_codes in $XSB/syslib/string.P

Other
open
nobody
5
2011-11-14
2011-11-14
No

Hi,

When I exchanged negative floats between xsb and java via interprolog I got an error.
I tracked this down to

extern_float_codes in $XSB/syslib/string.P

The current implementation
extern_float_codes(Float,Codes0,Codes) :-
Log10 is log(10),
Exp is floor(log(Float)/Log10-6), % to get 6 or 7 digits, Put . Exp to left from end
DigitsInt is floor(Float/exp(Exp*Log10)),
number_codes(DigitsInt,Digits),
length(Digits,Length),
Dist is Length+Exp,
(Dist > 0
-> place_decimal(Digits,Dist,Codes0,Codes)
; Codes0 = [0'0,0'.|Codes1],
prefix_decimal(Digits,Dist,Codes1,Codes)
).

does not work for negaitive floats.
But there is a very simple alternative that works well:
%% this alternative definition worked for me in xsb 3.2, Juk, 21.12.2009
extern_float_codes(Float,Codes0,Codes) :-
number_codes(Float,FC),
append(FC,Codes,Codes0),
!.

Best,
Juk

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks