From 36eddb686f6600b3bab7d63409ced0c3a9c654e9 Mon Sep 17 00:00:00 2001 From: Ben McDonald <46734217+bmcdonald3@users.noreply.github.com> Date: Tue, 11 Jul 2023 10:33:04 -0700 Subject: [PATCH] Add bigint bool casting In #22715, the request to cast from bool to bigint was requested, so that is being added here. Signed-off-by: Ben McDonald <46734217+bmcdonald3@users.noreply.github.com> --- modules/standard/BigInteger.chpl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/standard/BigInteger.chpl b/modules/standard/BigInteger.chpl index 9256edfcc79f..be29cb7d6b7c 100644 --- a/modules/standard/BigInteger.chpl +++ b/modules/standard/BigInteger.chpl @@ -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; @@ -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);