File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,8 @@ def self.log(x, prec)
233233
234234 x = BigDecimal ::Internal . coerce_to_bigdecimal ( x , prec , :log )
235235 return BigDecimal ::Internal . nan_computation_result if x . nan?
236- raise Math ::DomainError , 'Zero or negative argument for log' if x <= 0
236+ raise Math ::DomainError , 'Negative argument for log' if x < 0
237+ return -BigDecimal ::Internal . infinity_computation_result if x . zero?
237238 return BigDecimal ::Internal . infinity_computation_result if x . infinite?
238239 return BigDecimal ( 0 ) if x == 1
239240
Original file line number Diff line number Diff line change @@ -2352,8 +2352,9 @@ def test_BigMath_log_with_complex
23522352 end
23532353
23542354 def test_BigMath_log_with_zero_arg
2355- assert_raise ( Math ::DomainError ) do
2356- BigMath . log ( 0 , 20 )
2355+ BigDecimal . save_exception_mode do
2356+ BigDecimal . mode ( BigDecimal ::EXCEPTION_INFINITY , false )
2357+ assert_equal ( Math . log ( 0 ) , BigMath . log ( 0 , 20 ) )
23572358 end
23582359 end
23592360
Original file line number Diff line number Diff line change @@ -149,8 +149,7 @@ def test_log
149149 assert_converge_in_precision { |n | BigMath . log ( BigDecimal ( "1e-30" ) , n ) }
150150 assert_converge_in_precision { |n | BigMath . log ( BigDecimal ( "1e30" ) , n ) }
151151 assert_converge_in_precision { |n | BigMath . log ( SQRT2 , n ) }
152- assert_raise ( Math ::DomainError ) { BigMath . log ( BigDecimal ( "0" ) , 10 ) }
153- assert_raise ( Math ::DomainError ) { BigMath . log ( BigDecimal ( "-1" ) , 10 ) }
152+ assert_raise ( Math ::DomainError ) { BigMath . log ( BigDecimal ( "-0.1" ) , 10 ) }
154153 assert_separately ( %w[ -rbigdecimal ] , <<-SRC )
155154 begin
156155 x = BigMath.log(BigDecimal("1E19999999999999"), 10)
You can’t perform that action at this time.
0 commit comments