[Tutor] Single precision math in embedded Python, was Re: [Tutor] crash when importing random or sys module, in my embedded python

Magnus Lyckå magnus@thinkware.se
Fri Jun 20 11:42:02 2003


At 23:18 2003-06-19 -0400, R. Alan Monroe wrote:
>Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
>Type "help", "copyright", "credits" or "license" for more information.
> >>> import math
> >>> math.pi
>3.1415926535897931

Sure, in your non-embedded python environment. I bet
"import random" works without a hitch here.

But what if you do "import math; print math.pi" in your
embedded python environment. What does is say then?

> > version? Is your embedded version somehow using single
> > precision floating points instead of double?
>
>Since the error occurs during "import random", at the very top, I've
>not yet defined any variables at all :^)

You misunderstand me. This is a C issue, not a Python issue.
You can't control the precision of floats from within Python.

You have to look in your C project settings or include files
to find the root of this, I fear.

I'm wondering whether this affects all floating point numbers
in the embedded Python for you, or if it's just the math module
that is somehow flawed...

How does "print repr(0.1)" or "print repr(5.3)" etc look in
your embedded environment? And what about something like
"print repr(math.sin(1))"

Do they look identical with the output in your standard Python
environment (which is obviously acting quite normal).




--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language