Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:26:32+00:00 2026-05-24T13:26:32+00:00

I am trying to port a portion of a code written in a different

  • 0

I am trying to port a portion of a code written in a different language (an obscure one called Igor Pro by Wavemetrics for those of you have heard of it) to Python.

In this code, there is a conversion of a data type from a 16-bit integer (read in from a 16-bit, big endian binary file) to single-precision (32-bit) floating-point. In this program, the conversion is as follows:

Signed 16-bit integer:

print tmp
tmp[0]={-24160,18597,-24160,18597,-24160}

converted to 32-bit floating-point:

Redimension/S/E=1 tmp
print tmp
tmp[0]={339213,339213,5.79801e-41,0,0}

The /S flag/option indicates that the data type of tmp should be float32 instead of int16. However, I believe the important flag/option is /E=1, which is said to “Force reshape without converting or moving data.”

In Python, the conversion is as follows:

>>> tmp[:5]
array([-24160,  18597, -24160,  18597, -24160], dtype=int16)

>>> tmp.astype('float32')
array([-24160.,  18597., -24160., ...,  18597., -24160.,  18597.], dtype=float32)

Which is what I expect, but I need to find a function/operation that emulates the /E=1 option in the original code above. Is there an obvious way in which -24160 and 18597 would both be converted to 339213? Does this have anything to do with byteswap or newbyteorder or something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:26:34+00:00Added an answer on May 24, 2026 at 1:26 pm
    import numpy
    tmp=numpy.array([-24160,18597,-24160,18597,-24160, 0], numpy.int16)
    tmp.dtype = numpy.float32
    print tmp
    

    Result:

    [  3.39213000e+05   3.39213000e+05   5.79801253e-41]
    

    I had to add a zero to the list of value because there are an odd number of values. It cannot interpret those as 32 bit floats since there 5 16 bit values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to port a portion of AJAX code I wrote over to the
I'm trying to port some assembly code written in Visual Studio into GNU inline
I'm trying to port some C++ code to C#, and one of the things
I am trying to port this algorithm to clojure. My code is (defn calc-iterations
We are trying to port our code from HPX to AIX but getting core
I'm trying to port code over to compile using Microchip's C18 compiler for a
I'm trying to port some OpenGL rendering code I wrote for iOS to a
Trying to port java code to C++ I've stumbled over some weird behaviour. I
I trying to port a WinForms project to WPF. But I am have some
I'm trying to port a Matlab code to Java and C++. It's quite straightforward

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.