<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=709185021-06052008><FONT face=Arial
color=#0000ff size=2>Sorry for the reply. I did not get your message until
now. I was wondering if there was a way to develop floating-point
mathematics package within a module. I was wondering if some of your work
on bit twiddling floating - point numbers could be provided to me!!!
Thanks. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=709185021-06052008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=709185021-06052008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=709185021-06052008><FONT face=Arial
color=#0000ff size=2>David Blubaugh</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=709185021-06052008></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=709185021-06052008> </SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Jeff Goldfinkle
[mailto:jeff.goldfinkle@gmail.com] <BR><B>Sent:</B> Monday, April 28, 2008 2:10
PM<BR><B>To:</B> Blubaugh, David A.<BR><B>Subject:</B> Re: Bit twiddling
floating point numbers<BR></FONT><BR></DIV>
<DIV></DIV>sure - go right ahead<BR><BR>
<DIV class=gmail_quote>On Mon, Apr 28, 2008 at 8:17 PM, Blubaugh, David A.
<<A href="mailto:dblubaugh@belcan.com">dblubaugh@belcan.com</A>>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Are you
still out there? </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Can I
still ask you about my question?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>thanks,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>David</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN></SPAN> </DIV><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> Jeff Goldfinkle [mailto:<A
href="mailto:jeff.goldfinkle@gmail.com"
target=_blank>jeff.goldfinkle@gmail.com</A>] <BR><B>Sent:</B> Friday, March
07, 2008 1:04 AM<BR><B>To:</B> Blubaugh, David A.
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c><BR><B>Subject:</B> Re: Bit twiddling floating point
numbers<BR></DIV></DIV></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<DIV></DIV>Hi David<BR><BR>Sure. I'm not sure what help I can be, but ask
away.<BR><BR>Jeff<BR><BR><BR><BR>
<DIV class=gmail_quote>On Thu, Mar 6, 2008 at 11:25 PM, Blubaugh, David A.
<<A href="mailto:dblubaugh@belcan.com"
target=_blank>dblubaugh@belcan.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Jeff,<BR><BR><BR>Hello.
This idea or representing a float with long seems to be<BR>extremely
interesting. I am currently utilizing the MyHDL environment<BR>to map
algorithms to hardware. May I ask you more questions in order
to<BR>map integer mathematics to emulate floating -point mathematics, in
order<BR>to maybe develop efficient pseudo-floating-point
hardware??<BR><BR> Thanks,<BR><BR>David
Blubaugh<BR><BR><BR><BR><BR><BR>-----Original Message-----<BR>From: <A
href="mailto:Jeff.Goldfinkle@gmail.com"
target=_blank>Jeff.Goldfinkle@gmail.com</A> [mailto:<A
href="mailto:Jeff.Goldfinkle@gmail.com"
target=_blank>Jeff.Goldfinkle@gmail.com</A>]<BR>Sent: Thursday, March 06,
2008 4:01 PM<BR>To: <A href="mailto:python-list@python.org"
target=_blank>python-list@python.org</A><BR>Subject: Re: Bit twiddling
floating point numbers<BR><BR>On Mar 6, 11:00 am, Bryan Olson <<A
href="mailto:fakeaddr...@nowhere.org"
target=_blank>fakeaddr...@nowhere.org</A>> wrote:<BR>> Mark Dickinson
wrote:<BR>
<DIV>> > Jeff Goldfin wrote:<BR>> >> I can pack and unpack a
float into a long e.g.<BR>> >>
struct.unpack('I',struct.pack('f',0.123))[0]<BR>> >> but then I'm
not sure how to work with the resulting long.<BR>><BR>> >> Any
suggestions?<BR>><BR></DIV>> > One alternative to using struct is
to use math.ldexp and math.frexp:<BR>><BR>> >>>> m, e =
frexp(pi)<BR>> >>>> m<BR>> >
0.78539816339744828<BR>> >>>> e<BR>> > 2<BR>>
>>>> int(m*2**53)<BR>> > 7074237752028440L<BR>><BR>>
> Then you can do your bit twiddling on int(m*2**53), before
using<BR>> > ldexp to 'repack' the float.<BR>><BR>> Ah, those
are handy. Jeff described his problem: "In particular, I<BR>
<DIV>> would like to round my float to the n most significant
bits."<BR></DIV>> I think this works:<BR>><BR>> from
math import frexp, ldexp, floor<BR>><BR>> def
round_mantissa(x, nbits):<BR>> shifter = 1
<< nbits<BR>> (m, e) = frexp(x)<BR>>
m = floor(m * shifter + 0.5) / shifter<BR>>
return ldexp(m, e)<BR>><BR>> --<BR>>
--Bryan<BR>Thanks for the help - your function seems to fit the bill even
better<BR>than gmpy since I don't need an external module. In my case I'll
use m =<BR>floor(m * shifter) / shifter instead of m = floor(m * shifter
+<BR>0.5) / shifter<BR><BR>Jeff<BR><BR><BR><BR>This e-mail transmission
contains information that is confidential and may be<BR>privileged. It is
intended only for the addressee(s) named above. If you receive<BR>this
e-mail in error, please do not read, copy or disseminate it in any
manner.<BR>If you are not the intended recipient, any disclosure, copying,
distribution or<BR>use of the contents of this information is prohibited.
Please reply to the<BR>message immediately by informing the sender that the
message was misdirected.<BR>After replying, please erase it from your
computer system. Your assistance in<BR>correcting this error is
appreciated.<BR><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<P align=left><FONT color=#0000ff><FONT color=#000000 size=2>This e-mail
transmission contains information that is confidential and may be
privileged. It is intended only for the addressee(s) named above.
If you receive this e-mail in error, please do not read, copy or disseminate
it in any manner. If you are not the intended recipient, any disclosure,
copying, distribution or use of the contents of this information is
prohibited. Please reply to the message immediately by informing the sender
that the message was misdirected. After replying, please erase it from your
computer system. Your assistance in correcting this error is
appreciated.<BR></FONT></FONT></P></DIV></DIV></BLOCKQUOTE></DIV><BR></BODY><!--[object_id=#belcan.com#]--><FONT size=2>
<P>This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated.</P></FONT></HTML>