Re: fraclib.e

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hello Jim, you wrote:

> On Tue, Jan 21, 2003 at 10:28:04AM +0100, Juergen Luethje wrote:

<snipped by a human>

>>> It stores fractions as a 2 element biginteger sequence. (A biginteger
>>> is currently an atom thats restricted to whole numbers,
>>
>> I use 3 element biginteger (called "hugeint" by me smile) sequences, so
>> that my lib also can handle mixed numbers.
>
> Ah, mine handles those as inproper fractions. (1 and 1/3 is stored internally
> as {4, 3} rather than {1, 1, 3}, for example.) I chose this route for
> simplicity.

Simplicity is an advantage, of course.
On the other hand, we can do nice things with mixed numbers, e.g.
easily calculate with the time, and automatically get the result in an
appropriate format.
Say you start a job at half past seven AM, and it ends at a quater to
five PM. How long did it take?
      elapsed = f_sub({16, 45, 60}, {7, 30, 60})
   => elapsed = {9, 15, 60}   (9 hours and 15 minutes)

To achive this goal, in my lib the result of f_sub() and f_add() is
*not* automatically reduce()d, if the denominators of both numbers are
the same.

> How large can a hugeint be? Is it just an atom used as an integer,

Yes, that's it. Just another word for what you call 'biginteger'.

<snipped by a human>

> BTW, what would be really useful here, is a way to make a custom type
> which allows one to redefine the math operators, so I could do "f1 + f2"
> rather than "f_add(f1, f2)", but have the 2 mean the same thing. (I have a
> very simple parser to handle this for me however, to be added to Dredge,
> a.k.a.
> Euphoria++).

Interesting! Is it ready for public release? smile

Best regards,
   Juergen

-- 
 /"\  ASCII ribbon     |  while not asleep do
 \ /  campain against  |     sheep += 1
  X   HTML e-mail and  |  end while
 / \  news             |

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu