cmath-js 5.8.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,6 +47,7 @@ These functions accept either a `bigint` or an integer `number`:
47
47
  // Prints "The greatest common divisor of 24 and 32 is 8."
48
48
  console.log(`The greatest common divisor of 24 and 32 is ${gcd(24, 32)}.`);
49
49
  ```
50
+ - [`has_single_bit`](https://en.cppreference.com/cpp/numeric/has_single_bit)
50
51
  - [`lcm`](https://en.cppreference.com/cpp/numeric/lcm)
51
52
  - [`popcount`](https://en.cppreference.com/cpp/numeric/popcount)
52
53
 
@@ -0,0 +1 @@
1
+ export declare function has_single_bit(integer: bigint | number): boolean;
@@ -0,0 +1,7 @@
1
+ export function has_single_bit(integer) {
2
+ if (typeof integer === "number" && !Number.isInteger(integer)) {
3
+ return false;
4
+ }
5
+ return String(BigInt(integer)).lastIndexOf("1") === 0;
6
+ }
7
+ //# sourceMappingURL=has_single_bit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has_single_bit.js","sourceRoot":"","sources":["../../../src/namespace-std/integers/has_single_bit.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,cAAc,CAAC,OAAwB;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC"}
@@ -2,5 +2,6 @@ export { abs } from "./abs.ts";
2
2
  export * from "./count-left-or-right-bits/index.ts";
3
3
  export { div, type div_t, type div_t_bigint, type div_t_number } from "./div/index.ts";
4
4
  export { gcd } from "./gcd/gcd.ts";
5
+ export { has_single_bit } from "./has_single_bit.ts";
5
6
  export { lcm } from "./lcm/lcm.ts";
6
7
  export { popcount } from "./popcount.ts";
@@ -2,6 +2,7 @@ export { abs } from "./abs.js";
2
2
  export * from "./count-left-or-right-bits/index.js";
3
3
  export { div } from "./div/index.js";
4
4
  export { gcd } from "./gcd/gcd.js";
5
+ export { has_single_bit } from "./has_single_bit.js";
5
6
  export { lcm } from "./lcm/lcm.js";
6
7
  export { popcount } from "./popcount.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/namespace-std/integers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,GAAG,EAAoD,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/namespace-std/integers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,cAAc,qCAAqC,CAAC;AACpD,OAAO,EAAE,GAAG,EAAoD,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oskarlh/cmath-js.git"
7
7
  },
8
- "version": "5.8.0",
8
+ "version": "5.9.0",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",