I have the following code:
:-use_module(library(clpfd)).
afn(A,B,C):-
C
It works correctly with integers, but not with decimal numbers:
43 ?- afn(20, 10, C).
C = 200.
44 ?- afn(20, -10, C).
C = -200.
45 ?- afn(20, -10.5, C).
ERROR: Domain error: `clpfd_expression' expected, found `-10.5'
46 ?-
How can I work with decimals here? Thank.
Edit: I find the following works with decimal places:
afn(A,B,C):-
C is B * A.
67 ?- afn(20.895, 40.5, C).
C = 846.2475.
Is it right ??
source
share