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.
David Blubaugh
On Mar 6, 11:00 am, Bryan Olson <[EMAIL PROTECTED]> wrote:
> Mark Dickinson wrote:
> > Jeff Goldfin wrote:
> >> I can pack and unpack a float into a long
> >> e.g.
> >> struct.unpack('I',struct.pack('f',0.123))[0]
> >> but then I'm not sure how to work with the resulting long.
>
> >> Any suggestion
Mark Dickinson wrote:
> Jeff Goldfin wrote:
>> I can pack and unpack a float into a long
>> e.g.
>> struct.unpack('I',struct.pack('f',0.123))[0]
>> but then I'm not sure how to work with the resulting long.
>>
>> Any suggestions?
>
> One alternative to using struct is to use math.ldexp and math.fr
On Mar 5, 11:27 pm, Mensanator <[EMAIL PROTECTED]> wrote:
> On Mar 5, 2:25 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi All
>
> > Is there a simple way to twiddle the bits of a float? In particular, I
> > would like to round my float to the n most significant bits.
>
> > For exampl
On Mar 5, 2:25 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi All
>
> Is there a simple way to twiddle the bits of a float? In particular, I
> would like to round my float to the n most significant bits.
>
> For example - 0.123 in binary is 0.00011
> Rounding to 4 bits I get 0.0001.
>
On Mar 5, 3:25 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I can pack and unpack a float into a long
> e.g.
> struct.unpack('I',struct.pack('f',0.123))[0]
> but then I'm not sure how to work with the resulting long.
>
> Any suggestions?
One alternative to using struct is to use math.ldexp
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> thanks for the reply but I'm still unsure as to how to
> continue. Using the bitwise operators will help me deal with
> integers but I really want to work with floats.
In your original post, you said that you've got the values as
integ
On Mar 5, 10:48 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2008-03-05, Grant Edwards <[EMAIL PROTECTED]> wrote:
>
> > On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> Any suggestions?
>
> > Just use the bitwise and/or/not operators: & | ~
>
> Oh, I forgot to mention the shift
On 2008-03-05, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> Any suggestions?
>
> Just use the bitwise and/or/not operators: & | ~
Oh, I forgot to mention the shift operators << and >>
--
Grant Edwards grante
On 2008-03-05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Is there a simple way to twiddle the bits of a float? In particular, I
> would like to round my float to the n most significant bits.
>
> For example - 0.123 in binary is 0.00011
> Rounding to 4 bits I get 0.0001.
>
> I can pack and
Hi All
Is there a simple way to twiddle the bits of a float? In particular, I
would like to round my float to the n most significant bits.
For example - 0.123 in binary is 0.00011
Rounding to 4 bits I get 0.0001.
I can pack and unpack a float into a long
e.g.
struct.unpack('I',struct.pack('f
11 matches
Mail list logo