Comments (4)
First, the original issue text is very short, so I'm copying it here:
「Math.sqrt との対称性から、BigDecimal#sqrt は BigMath.sqrt として提供すべきでしょう。」
In other words, "BigDecimal#sqrt should be moved to BigMath.sqrt to be symmetric (parallel?) to Math.sqrt".
I don't mind aligning the interfaces, but I think it should be the other way round. With Ruby being such a thoroughly object-oriented language, I have never understood why I would have to write
Math.sqrt(25) when 25.sqrt would be much shorter, more convenient, and more Ruby-like.
My guess is that the reason for the functions being in the Math module are mostly historic. It's definitely not a question of memory footprint, because the Math module is built-in and doesn't have to be required.
[We may have to move this issue back to https://bugs.ruby-lang.org/issues/4968 because if done well, it will affect Ruby itself, too.]
from bigdecimal.
@duerst sqrt
is a mathematical function.
I think most people, including me, want to write sqrt(25)
instead of 25.sqrt
because the former notation is more natural in math than the latter.
from bigdecimal.
@mrkn I don't mind if some people sometimes want to write sqrt(25)
; I might want to do that occasionally, too.
But this is Ruby, and as a Rubyist, I feel quite okay with 25.sqrt
. Actually, I feel more than just right, I feel that it's very natural.
Even more, if sqrt
is a method on numeric objects, I can do things like array.map &:sqrt
. With the functional notation, that doesn't work.
If we want Ruby to be used more for numerical computation and similar applications, then making people familiar with Math feeling familiar with Ruby may be an important point, but we also have to make sure that these people can use Ruby to the fullest.
from bigdecimal.
@duerst Now Ruby's core numeric class don't have sqrt
as their instance methods.
As a maintainer of BigDecimal, I think I should let BigDecimal follow to core numeric classes.
It is the purpose of this issue.
It means that I will keep BigDecimal#sqrt
if core numeric classes have sqrt
instance methods.
But I don't want to write 25.sqrt
, so I won't create the new issue to propose sqrt
instance methods in core numeric classes.
Please create the new issue and discuss it in bugs.ruby-lang.org If you want.
from bigdecimal.
Related Issues (20)
- ERROR(VpDivd): space for remainder too small
- BigDecimal#round raises FloatDomainError regardless of exception mode HOT 2
- Comparison failure: 9.8.abs <= BigDecimal('9.8') => false HOT 4
- Inconsistent max precision affecting dump&load result HOT 4
- Inconsistency between Bigdecimal 3.0.x and 3.1.x HOT 4
- BigDecimal#n_significant_digits and #precision do not return the correct value HOT 1
- I would expect BigDecimal#divmod to return type [Int, BigDecimal] (like Integer#divmod, Float#divmod)
- mode(BigDecimal::EXCEPTION_ALL,true) did not throw an exception when bigdecimal#exponent overflowed HOT 1
- Integrate JRuby implementation into the gem
- Loss of precision on very large numbers in `to_d` HOT 1
- Incorrect calculation result after upgrading from BigDecimal 3.1.1 to 3.1.2 HOT 1
- Difference in behavior with and without BigDecimal#dev 'digit' argument
- nil.to_d inconsistent (bigdecimal/util)
- Installation Error of BigDecimal 3.1.5 in JRuby HOT 3
- ruby 3.0.6 compilation error on MacOS Sonoma 14 related to maybe_unused HOT 1
- Ruby 3.4 and BigDecimal. HOT 10
- Memory leak with BigDecimal::EXCEPTION_OVERFLOW HOT 2
- BigDecimal#whole? HOT 3
- Use RUBY_TYPED_EMBEDDABLE in BigDecimal
- Please publish 3.1.8-java gem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigdecimal.