Sujet : Re: "undefined behavior"?
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 15. Jun 2024, 06:05:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4j7ec$3ap16$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
On 6/15/24 00:45, DFS wrote:
On 6/14/2024 11:56 PM, Keith Thompson wrote:
DFS <nospam@dfs.com> writes:
On 6/14/2024 9:39 PM, Keith Thompson wrote:
...
I'm surprised you needed to convert i to an int. I would think that
> just replacing nums[i/2] by nums[i//2] would do the trick,
> as long> as i always has an int value (note Python's dynamic typing).
If i
is acquiring a float value, that's probably a bug, given the name.
I spotted the issue. Just prior to using i for array addressing I said:
i = N/2.
The fix is set i = int(N/2)
Alternatively, i = N//2
But if you want help with your Python code, comp.lang.python is the
place to ask.
Thanks for your help, but David Brown is a Python developer and I'll ask
him python questions here whenever I care to.
Keep in mind that he's just one Python developer. With all due respect
to David, you're likely to get better answers to your Python questions
by going to a Python forum filled with Python developers.
It's not about "following the rules" - rules are meaningless when
enforcement is impossible, as it is in an unmoderated newsgroup like
this one. It's about getting the best possible answer to your questions.
If you prefer get lower quality answers to your Python questions,
continue asking them in forums where they are off-topic - but why would
you prefer that?