Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Issue 1204993002: Change documentation of modInverse to not specify error thrown. (Closed)

Created:
5 years, 6 months ago by Lasse Reichstein Nielsen
Modified:
5 years, 5 months ago
Reviewers:
ricow1, *Søren Gjesse, regis
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Change documentation of modInverse to not specify error thrown. R=ricow@google.com, sgjesse@google.com Committed: https://github.com/dart-lang/sdk/commit/3300a005f28426adaa1f5b44415a82e644ee237d

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M sdk/lib/core/int.dart View 1 chunk +1 line, -1 line 4 comments Download

Messages

Total messages: 10 (3 generated)
Lasse Reichstein Nielsen
5 years, 6 months ago (2015-06-24 09:03:29 UTC) #3
Søren Gjesse
lgtm
5 years, 6 months ago (2015-06-24 09:03:54 UTC) #4
ricow1
lgtm
5 years, 6 months ago (2015-06-24 09:04:21 UTC) #5
Lasse Reichstein Nielsen
Committed patchset #1 (id:1) manually as 3300a005f28426adaa1f5b44415a82e644ee237d (presubmit successful).
5 years, 6 months ago (2015-06-24 09:04:32 UTC) #6
regis
DBC https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart File sdk/lib/core/int.dart (right): https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart#newcode91 sdk/lib/core/int.dart:91: * It is an error of [shiftAmount] is ...
5 years, 6 months ago (2015-06-24 18:29:54 UTC) #8
Lasse Reichstein Nielsen
https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart File sdk/lib/core/int.dart (right): https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart#newcode119 sdk/lib/core/int.dart:119: * Throws if no modular inverse exists. True. I ...
5 years, 5 months ago (2015-06-30 12:39:15 UTC) #9
regis
5 years, 5 months ago (2015-06-30 16:50:39 UTC) #10
Message was sent while issue was closed.
On 2015/06/30 12:39:15, Lasse Reichstein Nielsen wrote:
> https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart
> File sdk/lib/core/int.dart (right):
> 
>
https://codereview.chromium.org/1204993002/diff/1/sdk/lib/core/int.dart#newco...
> sdk/lib/core/int.dart:119: * Throws if no modular inverse exists.
> True.
> I haven't yet decided on whether it should be documented which error it throws
> in this case. It's not generally something the user can detect before calling,
> so they need to catch the error. For that reason we might want to specify
which
> error object is thrown.

It is why I had specified RangeError (a bad choice of exception) in the
description.

> The actual error would probably be UnsupportedError (ArgumentError could be
> argued, but it's not that the argument is bad, it just that there is no
solution
> to the question you are asking, RangeError doesn't fit). Maybe we should even
> have an ArithmeticException - because its something the user will want to
catch,
> so it should be an exception.
> 
> Or we could just return 0, which is never a valid inverse.

As I mentioned elsewhere, 0 is a valid answer:
x.modInverse(1) = 0 for any x, because x*0 mod 1 == 1.

But -1 would work. I'd still prefer throwing an exception.

Powered by Google App Engine
This is Rietveld 408576698