Re: Python equivalent to the "A" or "a" output conversions in C

Discussion in 'Python' started by Edward C. Jones, Jun 19, 2012.

  1. On 06/19/2012 12:41 PM, Hemanth H.M wrote:

    > >>> float.hex(x)

    > '0x1.5000000000000p+3'
    >

    Some days I don't ask the brightest questions. Suppose x was a numpy
    floating scalar (types numpy.float16, numpy.float32, numpy.float64, or
    numpy.float128). Is there an easy way to write x in
    binary or hex?
    Edward C. Jones, Jun 19, 2012
    #1
    1. Advertising

  2. Edward C. Jones

    jmfauth Guest

    On Jun 19, 9:54 pm, "Edward C. Jones" <> wrote:
    > On 06/19/2012 12:41 PM, Hemanth H.M wrote:
    >
    > > >>> float.hex(x)

    > > '0x1.5000000000000p+3'

    >
    > Some days I don't ask the brightest questions.  Suppose x was a numpy
    > floating scalar (types numpy.float16, numpy.float32, numpy.float64, or
    > numpy.float128).  Is there an easy way to write x in
    > binary or hex?


    I'm not aware about a buitin fct. May be the module
    struct — Interpret bytes as packed binary data can help.

    jmf
    jmfauth, Jun 19, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Stromberg
    Replies:
    2
    Views:
    471
    Michael Spencer
    Jan 22, 2005
  2. Replies:
    10
    Views:
    698
    Jasen Betts
    Aug 5, 2005
  3. John Bokma

    Is there a $. equivalent for output?

    John Bokma, Sep 4, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    83
    John Bokma
    Sep 5, 2003
  4. Edward C. Jones
    Replies:
    1
    Views:
    239
    Alexander Blinne
    Jun 19, 2012
  5. Mark Lawrence
    Replies:
    0
    Views:
    249
    Mark Lawrence
    Jun 19, 2012
Loading...

Share This Page