Skip to content

Conversation

aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Sep 29, 2025

Numbers exceeding 2**63 are now automatically inferred as abstractFloat, since it could not fit in an abstractInt anyway.
Now the following does not warn, and the cast is unnecessary.
const FLT_MAX = f32(3.40282346e38);

You could argue that we should cast all numbers exceeding safe integers (~2**53) to floats, and that might be correct. Can you help me decide?

Copy link

github-actions bot commented Sep 29, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@626b21cdb5adc8f37480dd3afe66b52588db68ec
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@626b21cdb5adc8f37480dd3afe66b52588db68ec
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@626b21cdb5adc8f37480dd3afe66b52588db68ec

benchmark
view benchmark

commit
view commit

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes big integer handling for floating-point literals in the TGSL type system. The fix ensures that very large numeric literals (beyond 2^63) are treated as abstract floats rather than integers, eliminating the need for explicit f32 casts.

  • Added a check in numericLiteralToSnippet to handle values exceeding 2^63 as abstract floats
  • Removed unnecessary f32 casts from floating-point constants like FLT_MAX

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/typegpu/src/tgsl/generationHelpers.ts Added logic to treat large numeric literals as abstract floats
packages/typegpu-color/src/oklab.ts Removed unnecessary f32 cast from FLT_MAX constant
packages/typegpu/tests/examples/individual/oklab.test.ts Updated test expectation to match new FLT_MAX format

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review September 30, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant