Skip to content

Commit

Permalink
Add bigint bool casting
Browse files Browse the repository at this point in the history
In #22715, the request to cast from bool to bigint was requested,
so that is being added here.

Signed-off-by: Ben McDonald <[email protected]>
  • Loading branch information
bmcdonald3 committed Jul 11, 2023
1 parent 44b5fc8 commit 36eddb6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/standard/BigInteger.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,11 @@ module BigInteger {
return new bigint(src);
}

@chpldoc.nodoc
inline operator :(src: bool, type toType: bigint): bigint throws {
return new bigint(src:int);
}

@chpldoc.nodoc
inline operator :(const ref x: bigint, type t:numeric) where isIntType(t) {
var ret: c_long;
Expand Down Expand Up @@ -588,8 +593,7 @@ module BigInteger {
} else if x.localeId == chpl_nodeID {
ret = mpz_get_ui(x.mpz);

} else {
const xLoc = chpl_buildLocaleID(x.localeId, c_sublocid_any);
} else { const xLoc = chpl_buildLocaleID(x.localeId, c_sublocid_any);

on __primitive("chpl_on_locale_num", xLoc) {
ret = mpz_get_ui(x.mpz);
Expand Down

0 comments on commit 36eddb6

Please sign in to comment.