Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!zephyr.ens.tek.com!tektronix!percy!m2xenix!puddle!p6.f202.n281.z2.fidonet.org!Ben.Stuyts From: Ben.Stuyts@p6.f202.n281.z2.fidonet.org (Ben Stuyts) Newsgroups: comp.lang.modula2 Subject: Re: Overloading? Message-ID: <4241.2828FEB7@puddle.fidonet.org> Date: 6 May 91 03:50:04 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 2:281/202.6 - ST Quick BBS Haarle, Haarlem Holland Lines: 56 >> You cannot simply use (assuming you have 16-bit INTEGERs): >> >> fix3 := (fix1 * fix2) DIV 256; >> >> as this would cause an overflow during the multiplication. GE> GE> So then you'd use LONGINT... I could, but don't really want to because of the performance penalty. The only reason I'd have for using LONGINT's would be to have better precision. For example, assuming 32-bit LONGINT's, I could use a +/- .31 representation. Again, this would cause overflows in certain situations. GE> Actually, I'm a little confused about each other's intentions. GE> For fixed point, I was thinking of scaling for decimal representation, GE> not binary as your example implies. Correct, I am looking at binary representations. More or less based on those of DSP's, so that it would be easy to convert all this stuff over to a DSP. GE> I agree, however, that it sometimes is inconvenient to not have GE> customary operators available. On the other hand, it is seldom, GE> with simple numeric representations, necessary to go outside of GE> what is already provided by the language. Well, it doesn't really matter if you talk about fixed point numbers or, for example, complex numbers. Yet in the case of complex numbers, the powers that be have opted to incorporate them into the language. It seems to me that adding operator overloading would have been a solution to *both* problems. >> The same problem obviously applies to division and also to other >> representations for fixed point numbers like +/-.15 bit. GE> GE> Again, I think we're thinking of different ideas here. My GE> understanding of fixed point numbers is that if you're trying to GE> divide by a fraction of a bit, then you've picked the wrong range or GE> you must represent the fraction-of-a-bit as a continued fraction GE> approximation. GE> Could you enlighten me? What do you mean by dividing by a fraction of a bit? What is so uncommon about division of fixed point numbers? It is particularly important for fixed point arithmatic to be able to scale the numbers properly. The only generic ways I know to do this are by division or multiplication. Best regards, Ben -- uucp: uunet!m2xenix!puddle!2!281!202.6!Ben.Stuyts Internet: Ben.Stuyts@p6.f202.n281.z2.fidonet.org