From mboxrd@z Thu Jan 1 00:00:00 1970 References: <20111002163800.GA12773@polynum.com> <20111002175227.2D7F1B856@mail.bitblocks.com> <20111002182846.GA20646@polynum.com> <20111002190618.54195B852@mail.bitblocks.com> <20111003114131.GA7326@polynum.com> <1FC8ACD9-092B-43DB-8FF5-206FA5E02C55@bitblocks.com> <5c40d8ac0708e6def897a2f6807e20f1@chula.quanstro.net> In-Reply-To: <5c40d8ac0708e6def897a2f6807e20f1@chula.quanstro.net> Mime-Version: 1.0 (iPhone Mail 8L1) Content-Type: text/plain; charset=us-ascii Message-Id: <5A54BCA4-D759-4EDC-9B9E-2259E654EF68@bitblocks.com> Content-Transfer-Encoding: quoted-printable From: Bakul Shah Date: Mon, 3 Oct 2011 08:29:40 -0700 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] circular fonctions: precision? Topicbox-Message-UUID: 302a0f16-ead7-11e9-9d60-3106f5b1d025 On Oct 3, 2011, at 7:46 AM, erik quanstrom wrote: >> On Oct 3, 2011, at 4:41 AM, tlaronde@polynum.com wrote: >> >>> But to come back to programming, when calculus is the crux, the more >>> common/known even new! programming languages are not great tools, >>> and "portability" i.e. proved accuracy of the implementation for a >>> wide range of hardware/software is fuzzy. And it's amazing to see >>> how one can rapidly face errors even with very basic computations. >>> And even with integer arithmetic, not much help is guaranteed by >>> languages. >>>=20 >> Integer & rational arithmetic is guaranteed in Scheme and some other >> languages. In an R5RS compliant Scheme implementation you have for >> example (/ 5 7) =3D> 5/7. (If only people get over their irrational >> fear of prefix syntax they would discover a great little language in >> Scheme.) But most prog. languages do not specify minimal required >> accuracy on standard floating pt. functions. May be because most >> language hackers are not numerical analysts! >=20 > i think you've got it there. how do i stuff 5/7 in a 32-bit ethernet regi= ster? > if you're close to the h/w, it's probablly just confusing to fight it. Ethernet ctlrs have FP registers these days? Wow! It is just a different fig= ht. Scheme has conversion functions + macros to do what you want. Also note t= hat most people do not work as closely to h/w as perhaps you or I do. And of= course, you don't have to use just one language. Funny you mention h/w. I have used scheme in the past for h/w testing as wel= l as for generating code for a custom network processor. This NP had a 512 b= it barrel shifter (could hold an entire 64 byte pkt and we could poke at any= bitfield upto 32 bits in length). In my test library a 'shift' was (+ (quot= ient 512-bit-reg 2^32) new-32-bit-value)). Could've done in C but this was m= ore fun and far fewer lines of code and far quicker to develop! I could repr= esent an entire test pkt as a single number and shift into the barrelshifter= etc. No need to worry about grotty indexing or off by 1 errors!=20