Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Why Ruby doesn’t provide a `Complexe#modulo` method?

Ruby defines Numeric#%, aka Numeric#modulo to provide the remaining of receiver divided by an other Numeric. However, as the code bellow show, Complex is the only derived type which doesn’t provide a method for it:

ObjectSpace.each_object(Class){p "#{_1}: #{_1.method_defined?(:%)}" if _1.ancestors.include?(Numeric) unless _1 == Numeric}
"Complex: false"
"Rational: true"
"Float: true"
"Integer: true"
"Date::Infinity: true"

Is there a mathematical reason to avoid providing a reminder of complex numbers? In all cases, is there a documented reason for this engineering design choice?

Provision of an implementation of this operator for Complex, highlighting possible pitfall avoided if any, would also be welcome but more marginal for the topic of this question.

Side note: this as nothing to do with the notion of complex modulus, aka norm, which is also absent from Ruby standard library.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Back in 2009, in Bug #1712, Matz says:

I don't think there's natural definition of modulo on complex numbers, so that we should undefine % method.

As a result, Complex doesn't have %, modulo, or divmod. (among others)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!