GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — behaviour of the modulo operator · Issue #129297 · python/cpython

behaviour of the modulo operator #129297

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
behaviour of the modulo operator#129297
Copy link

Description

@SerpentByte
SerpentByte
opened on Jan 25, 2025
Issue body actions

Feature or enhancement

Proposal:

The behaviour of the modulo operator should be made consistent across Python and C/C++.

3%2 # this is 1
-3%2 # this can be represented as -1 or 1 depending of the divisor.
# -3%2 is -1 in C/C++.

Has this already been discussed elsewhere?

I don't think so.

Reacted by Stefan

Activity

  1. SerpentByte
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 25, 2025
  2. sobolevn commented on Jan 25, 2025

    @sobolevn
    sobolevn
    on Jan 25, 2025
    Member
    More actions

    Looks like a duplicate of #75204

  3. ronaldoussoren commented on Jan 25, 2025

    @ronaldoussoren
    ronaldoussoren
    on Jan 25, 2025
    Contributor
    More actions

    The behaviour of the operator is intentional, see the answers in this stack overflow question for a good explanation of the rationale for this choice.

    Reacted by Terry Jan Reedy, Petr Viktorin and Wasim
  4. ronaldoussoren
    closed this as not plannedon Jan 25, 2025
  5. Eclips4
    removed
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 25, 2025
  6. terryjreedy commented on Jan 26, 2025

    @terryjreedy
    terryjreedy
    on Jan 26, 2025
    Member
    More actions

    Issue #75204 is not really a duplicate; it is an open proposal to revise the int division programming FAQ, which involves the choice of modulus sign determination. I just opened PR #129313 for it. It needs coredev review.

    Reacted by Wasim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.