Am 25.10.2011 18:33, schrieb Aaron Meurer:
The issue report suggests testing for non-"intness" via
int(N) != N
What's the best way to test for "floatness" in Python?
This is not what the issue suggests.
Why is this important?
More specifically, I do not fully understand why extending the issue to
cover more functions is okay, but extending the domain of parameter values
is not.
Might be some ramifications that I don't know yet - in which case I'd like
to know :-)
I'm afraid I don't understand what you're asking here. If you're asking why
you can't use floats, you can. Calling int() on a float will truncate it,
but it doesn't matter, because it's just a range over the integers.
Actually, I guess you would really need to call ceil() in that case.
Did I understand your question correctly?
That's answers I already had, so, I fear that's not the case :-)
I see that the functions in generate.py fall into two classes:
1. Those that identify primes by index. I.e. you ask for the tenth prime
and get 23.
For these, calling int() would be just fine; asking for the 2.5th prime
would not make much sense after all.
2. Those that identify primes by magnitude. I.e. you ask for the list of
primes between 20 and 30 and get [23, 29].
For these, I'm suggesting to use float(), so we can ask for the list of
primes between 19.5 and 30.5. In fact, primerange(19.5, 30.5) would do
exactly that, which is what got me thinking in that direction in the
first place :-)
Aaahh... I wasn't aware that int(some_float) simply truncates some_float
to its integer part, which would be as useful for searching in the
primes array as a float (and maybe be a bit faster).
Now I'm wondering why primerange(a, b) uses float()...
Regards,
Jo
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.