[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how does print-to-codes work?
From: |
Jasper Taylor |
Subject: |
Re: how does print-to-codes work? |
Date: |
Thu, 12 Sep 2002 14:10:45 +0100 |
User-agent: |
KMail/1.4.1 |
On Thursday 12 Sep 2002 11:17 am, Daniel Diaz wrote:
> Try to use get_print_stream/1 inside your portray predicate: like:
>
> portray(F) :-
> float(F),
> format_to_codes(Fs, "~6f", [F]),
> append(Ns, Os, Fs),
> \+ (member(Ch, Os), \+ member(Ch, "0.")), !,
> get_print_stream(Stream),
> format(Stream,"~s",[Ns]).
>
>
> This should work
Yes, it does, thanks very much -- my mistake for not reading the manual
thoroughly enough.
However I am getting some bizarre behaviour -- the behaviour of print_to_codes
seems erratic, and this causes problems with my application. Here is an
example I tried on two different machines (both RedHat 7.3) to show you what
I mean, and note that varying the order of calls even a little can change the
outcome...nicefloat contains the predicate listed above...
$ gprolog
GNU Prolog 1.2.14
By Daniel Diaz
Copyright (C) 1999-2002 Daniel Diaz
| ?- print(2.92).
2.9199999999999999
yes
| ?- print_to_codes(A,2.92).
A = [50,46,57,49,57,57,57,57,57,57,57,57,57,57,57,57,57,57]
yes
| ?- consult(nicefloat).
compiling /win98/Program Files/Simile/Develop/Tests/nicefloat.pl for byte
code...
/win98/Program Files/Simile/Develop/Tests/nicefloat.pl compiled, 9 lines read
- 1616 bytes written, 8 ms
yes
| ?- portray(2.92).
2.92
yes
| ?- print(2.92).
2.92
yes
| ?- print_to_codes(A,2.92).
A = [50,46,57,50]
yes
| ?- print_to_chars(A,2.92).
A = ['2','.','9','2']
yes
| ?- print_to_codes(2.92).
uncaught exception:
error(existence_error(procedure,print_to_codes/1),top_level/0)
| ?- print_to_codes(A,2.92).
A = [50,46,57,50]
yes
| ?- print_to_chars(A,2.92).
A = [à,á,'\x12\','B',à,á,'\x12\','B']
yes
| ?- print_to_codes(A,2.92).
A = [224,225,18,66,224,225,18,66]
yes
| ?- print(2.92).
2.92
yes
| ?- print_to_codes(A,2.92).
A = [224,225,18,66,224,225,18,66]
yes
| ?-
Any workaround would be welcome !!
--Jasper