Re: [pure-lang-users] Numeric Arguments
Status: Beta
                
                Brought to you by:
                
                    agraef
                    
                
            | 
     
      
      
      From: Eddie R. <er...@bm...> - 2008-07-08 12:24:44
      
     
   | 
On Tue, 2008-07-08 at 09:44 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > A reasonable manner suggests x = (x mod N) + (x div N) * N > > ... where x div N is integer and abs (x mod N) < abs N I guess, with x > mod N the same sign as x? Yes. > That implicit definition should work with any combination of real-valued > operands (provided that N is nonzero, of course). Division of a complex > by a real could be lifted from that, but I'm not sure whether we > actually want it? Please don't implement the complex stuff. Implementing mathematics libraries is kind of like boxing, unless you spend a lot of time in the ring, you are going to get your jaw jacked. In my *very humble opinion*, if we want to implement anything, that would be mod and div operators that obey Scheme's R6RS rules as you alluded to below. > And we need to decide what to do with division by zero. Machine int and > bigint division both raise a SIGFPE right now (at least on Linux), which > is a bit inconvenient. ;-) They could be made undefined like in Q. That > will complicate and slow down the code for machine int division, though; > right now this is just a single sdiv instruction. Therefore I'd prefer > to install a signal handler which maps SIGFPE to a corresponding Pure > exception; that wouldn't incur runtime costs. In any case rational > division should follow suit (it returns a floating point infinity right > now). Opinions? Hmmm. I really don't know. Playing around with computer mathematics is one thing. Getting it right for the masses is a *monster*. Maybe bring it up before other language designers and see what they say. > Then it probably follows R5RS. AFAICT R6RS specifies div and mod (and > variations) which work with all real (but not with complex) arguments. It looks like they ditched quotient, remainder, and modulo for new functions div, div0, mod, mod0, div-and-mod, and div0-and-mod0. I'm not sure I want to vote for anything right now. e.r.  |