Re: [pure-lang-users] Numeric Arguments
Status: Beta
Brought to you by:
agraef
|
From: Libor S. <li...@gm...> - 2008-07-07 22:50:30
|
Eddie, you are right that C's fmod is different. What I was after was just "double mod int" which seems pretty innocuous to me. I have defined it myself and it saved me lots of lines of repetitious code to duplicate everything for ::int and ::double, so I thought others might also benefit from its addition. I note what Albert had to say on the matter and it is OK by me. It is no big deal, I can live with my own definition if it is not added. Albert did mention div which is a similar beast. Various misguided historical precedents notwithstanding, I would prefer the following behaviour: Both to accept all types of numerical arguments. div to "narrow" ie. if either argument is an int, return int / to "widen", ie. if either argument is a double, return double This is more forgiving and consistent, therefore imho more in the "pure" spirit. However, I guess ultimately it is just a personal preference. L. On Mon, 07 Jul 2008 22:20:35 +0100, Eddie Rucker <er...@bm...> wrote: >> > // mod of a double >> > x::double mod y::int = (x - intx) + (intx mod y) when intx = (int x) end; >> >> If memory serves me, Common Lisp has this, but not any Algol-like >> language I know. I can add it to math.pure if there's enough demand. > > I've had to deal with this once in Pascal somewhere before but I cant > recall. In that occasion I found that mod(double, double) may be defined > in two ways in order to stay consistent with something else ... Dang I > can't find it on google. > > I don't know if you should add "double mod double" to the list or not > but I sure would hate to have to look it up again. If memory servers me > (probably doesn't) C's definition of fmod really should be called frem > instead because there is a difference between real mod and real > remainder. I guess I better shut up now before I stick my foot in my > mouth. > > e.r. > > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source project, > along with a healthy diet, reduces your potential for chronic lameness > and boredom. Vote Now at http://www.sourceforge.net/community/cca08 > _______________________________________________ > pure-lang-users mailing list > pur...@li... > https://lists.sourceforge.net/lists/listinfo/pure-lang-users > |