473,320 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: complex representation

DSM wrote:
ISTM the same reasoning applies equally to complex numbers. My interest
arose because of what I think is a bug in pypy's complex printing:
Python 2.4.1 (pypy 1.0.0 build 56124) on linux2
Type "help", "copyright", "credits" or "license" for more information.
``RPython: we use it so you don't have to''
>>>(1.1+1.1j)**200
(240733537691613523198532543387690598400L+23649556 5429619338248192Lj)
This strangeness comes about because a hack used to recover cpython's
behaviour fails at large values. (x.real == floor(x.real), so it
decides the value's an integer, and returns the repr of int(x.real).)
It's trivial to fix but I think cpython's behaviour is slightly odd
here, and the real and imaginary parts of the complex repr should be
identical to those of the underlying floats.
CPython 2.4, 2.5, and 3.0 on WinXP (and hence I presume 2.6) produce
(with a trivial variation)
>>(1.1+1.1j)**200
(2.407335376916204e+38+2.3649556542962612e+23j)

That Pypy disagrees in the 14th digit is a bit odd, but I suspect a C
math library difference. Unless they are actually calculating 40 digits
exactly, the extra digits should be filled with 0s if they want
integers. Take that, and whatever you think is strange, up with them.

Jul 8 '08 #1
0 756

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marc te Vruchte | last post by:
Over the past years i've been in contact with the same problem a number of times, creating a graphical user interface on complex XML documents. Personally these solutions have never been...
7
by: seia0106 | last post by:
Hello, Writing a program in c++ that should use complex numbers I have two choices before me. 1- define a struct for complex data i.e struct {float real,imag; }ComplexNum; 2-use an array...
17
by: Chris Travers | last post by:
Hi all; I just made an interesting discovery. Not sure if it is a good thing or not, and using it certainly breakes first normal form.... Not even sure if it really works. However, as I am...
4
by: Gerald I. evenden | last post by:
I have found that with the Gnu compiler that undocumented output of a "double comple" value can be successfully performed by: double complex v; printf("%g %gi\n",v); which will print the...
4
by: Mantorok Redgormor | last post by:
With what specifier do I use to print a variable of a complex type? The man page for printf doesn't even say. - nethlek
5
by: Glen Low | last post by:
Suppose I have a complex number as follows: double _Complex d; Can I access the real part as ((double*) d) and the imaginary part as
11
by: of | last post by:
a = 1+3j complex(str(a)) Why does this not work ? It should
6
by: narutocanada | last post by:
hi I think complex numbers should respect the "i" or "I" representation, instead of "j". No reason being cute and using a different character instead of the traditional representation? At least...
0
by: DSM | last post by:
From the nothing-is-so-trivial-it's-not-worth-a-usenet-post file: Shouldn't the default representation of complex numbers be like that of floats? That is, have a decimal point? 1 1.0 1j 1j...
0
by: Robert Kern | last post by:
DSM wrote: Not necessarily. The reason that having floats always have a decimal point is desirable is to ensure roundtripping through eval(repr(x)). The j is sufficient for complexes. There are...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.