Re: bad pi
- From: Jan Wielemaker <jan@xxxxxxxxxxxx>
- Date: 29 Apr 2005 15:52:14 GMT
On 2005-04-29, An Ony <nowhere@xxxxxxxxxxxxx> wrote:
> Hi,
>
> (there's actually not one programming language I know that can do this, but)
> is there any way to make prolog give me
> X = 5*pi
> when I ask
> X is 3*pi + 2*pi
> and not
> X = 15.708
As such, no. It would be broken as is/2 is supposed to return a number.
You'd either have to write your own (symbolic) evaluator or you can change
the printing:
portray(X) :-
float(X),
Y is X/pi,
abs(Y*pi - X) < 1e-10,
format('~w*pi', [Y]).
?- A is 2*pi + 3*pi.
A = 5*pi
You see immediately the trouble, floats rarely match using == ...
Cheers --- Jan
.
- Follow-Ups:
- Re: bad pi
- From: An Ony
- Re: bad pi
- References:
- bad pi
- From: An Ony
- bad pi
- Prev by Date: Re: Non dominating queens problem
- Next by Date: Re: Help with structures
- Previous by thread: bad pi
- Next by thread: Re: bad pi
- Index(es):
Relevant Pages
|
|