Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ import { stringToBigInt } from "k-number-utils"
// Basic ASCII string - returns BigIntCoercion instance
const hello = stringToBigInt("hello")
hello.toBigInt() // 448378203247n
hello.toInt32() // 1818522991
hello.toInt32() // 1701604463
hello.toUint8() // 111 (lower 8 bits)

// Single character
Expand All @@ -312,8 +312,8 @@ stringToBigInt("🚀").toBigInt() // 4036991616n
stringToBigInt("🚀").toInt32() // -257975680

// Chinese characters
stringToBigInt("你好").toBigInt() // 15060223084n
stringToBigInt("你好").toChar() // '' (lower 16 bits)
stringToBigInt("你好").toBigInt() // 251503099356605n
stringToBigInt("你好").toChar() // '' (lower 16 bits)

// Mixed content
const mixed = stringToBigInt("Hello 🌍")
Expand Down
4 changes: 2 additions & 2 deletions src/bigint-coercion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* const bn = new BigIntCoercion(123456789n);
* bn.toInt32(); // 123456789
* bn.toUint8(); // 21 (truncated to 8 bits)
* bn.toChar(); // 'Í' (Unicode character from lower 16 bits)
* bn.toChar(); // '' (Unicode character from lower 16 bits)
*
* @example
* // Collision example - large values wrap around
Expand Down Expand Up @@ -242,7 +242,7 @@ export class BigIntCoercion {
* @example
* new BigIntCoercion(65n).toChar(); // 'A'
* new BigIntCoercion(8364n).toChar(); // '€' (Euro sign)
* new BigIntCoercion(128512n).toChar(); // '😀' (would wrap to 16 bits)
* new BigIntCoercion(128512n).toChar(); // '' (wraps to 16 bits: 62976)
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment shows an empty string ('') but should show the actual Unicode character for code point 62976. Consider using String.fromCharCode(62976) to show the correct character or explain why it appears empty.

Suggested change
* new BigIntCoercion(128512n).toChar(); // '' (wraps to 16 bits: 62976)
* new BigIntCoercion(128512n).toChar(); // '' (wraps to 16 bits: 62976)

Copilot uses AI. Check for mistakes.

*/
toChar(): string {
const codePoint = this.toUint16()
Expand Down