Re: Fractional part of decimal value.
Michael Hendricks <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAFHuXuZZkA=V0g-kvoVwcEatUioQJPh4Hs0_Q2Dc97kTSaF4UQ@mail.gmail.com> |
On Wed, Aug 7, 2013 at 8:38 AM, Wouter Beek <[email protected]> wrote: > My question is whether this can be circumvented for my simple/naive use. > (Preferably a solution that does not involve a hack such as using > format-to-codes and then number_codes/2 :-P.) > Depending on what you're trying to do, you could use rational numbers: decimal_parts(D,I,F) :- I is floor(D), F is rationalize(D) - I. Arithmetic performance is rarely a concern for me, so I tend to prefer rationals over floats in most applications. -- Michael -------------- next part -------------- HTML attachment scrubbed and removed