Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: James Kuyper Newsgroups: comp.lang.c Subject: Re: "undefined behavior"? Date: Sat, 15 Jun 2024 01:05:16 -0400 Organization: A noiseless patient Spider Lines: 34 Message-ID: References: <666a095a$0$952$882e4bbb@reader.netnews.com> <8734ph7qe5.fsf@nosuchdomain.example.com> <666a226d$0$951$882e4bbb@reader.netnews.com> <666b0451$0$953$882e4bbb@reader.netnews.com> <666ccccb$0$973$882e4bbb@reader.netnews.com> <87r0cz3rx5.fsf@nosuchdomain.example.com> <666d0f4f$0$979$882e4bbb@reader.netnews.com> <87msnm505i.fsf@nosuchdomain.example.com> <666d1c61$0$953$882e4bbb@reader.netnews.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 15 Jun 2024 07:05:17 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a3382237f06b294e6fe34b3474fc2487"; logging-data="3499046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18F0MRI6voKoL4KEQqTtQ7mBZyiWonK/ug=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:b4nFAFR3eEElEtu8Q4wG8WvBabU= Content-Language: en-US In-Reply-To: <666d1c61$0$953$882e4bbb@reader.netnews.com> Bytes: 2934 On 6/15/24 00:45, DFS wrote: > On 6/14/2024 11:56 PM, Keith Thompson wrote: >> DFS 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?