Jump to content

64bit float to 32bit float


0rr

Recommended Posts

Hi,

I hope someone can help me on this. As far as I know all floats in python are 64-bit.

How can I convert a 64Bit float to a 32Bit float in python?

afaik you can create and pass through C types in python using ctypes module, ctypes.c_float for examples, but as I understand using *.value will convert it back to native python type (?)

Link to comment
Share on other sites

Thanks for your help.

But I can't import the ctypes module. I get an error:

line 10, in <module>

from _ctypes import Union, Structure, Array

ImportError: No module named _ctypes

Importing any module works.

Maybe I should try numpy instead?

Link to comment
Share on other sites

What system? Python interpreter version? Ctypes is a standard module from python 2.5. Are you calling it from within Houdini? It's possible that it's not included in Houdini's python distribution on Windows, Can't check it now. On Linux it works though. If there is no such module for you, you can install it manually,

Link to comment
Share on other sites

Thanks again,

I am working with windows7 64bit. I am using the standart python interpreter that came with Houdini that is version 2.5.2. The ctypes moudle is in the houdini python/lib folder and already came with houdini. Using the standart python shell I don't get such an error and everythings working.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...