Title: PowerShell doesn't understand unsigned numbers · Issue #3313 · PowerShell/PowerShell · GitHub
Open Graph Title: PowerShell doesn't understand unsigned numbers · Issue #3313 · PowerShell/PowerShell
X Title: PowerShell doesn't understand unsigned numbers · Issue #3313 · PowerShell/PowerShell
Description: Steps to reproduce Description: I can't make powershell use correctly types like [uint32] or [uint64]. It seems like it always tries to dumb down every number to [int], and does it poorly. The bug seems to be that PS doesn't realize that...
Open Graph Description: Steps to reproduce Description: I can't make powershell use correctly types like [uint32] or [uint64]. It seems like it always tries to dumb down every number to [int], and does it poorly. The bug ...
X Description: Steps to reproduce Description: I can't make powershell use correctly types like [uint32] or [uint64]. It seems like it always tries to dumb down every number to [int], and does it poorly. The ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3313
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PowerShell doesn't understand unsigned numbers","articleBody":"Steps to reproduce\r\n------------------\r\nDescription: I can't make powershell use correctly types like [uint32] or [uint64]. It seems like it always tries to dumb down every number to [int], and does it poorly. The bug seems to be that PS doesn't realize that is has to upcast 0xffffffff to int64 and not to int32, as it won't fit.\r\n\r\nPS C:\\> [uint32]$b=0xffffffff\r\nCannot convert value \"-1\" to type \"System.UInt32\". Error: \"Value was either too large or too small for a UInt32.\"\r\n\r\nPS C:\\> $b=[uint32]0xffffffff\r\nCannot convert value \"-1\" to type \"System.UInt32\". Error: \"Value was either too large or too small for a UInt32.\"\r\n\r\nPS C:\\> $b=[uint64]0x1ffffffff\r\n\u003cso this works, because powershell realizes that 1ffffffff doesn't fit into 31 bit>\r\n\r\nPS C:\\> $b=[uint64]0xffffffff\r\nCannot convert value \"-1\" to type \"System.UInt64\". Error: \"Value was either too large or too small for a UInt64.\"\r\n\r\nExpected behavior\r\n-----------------\r\nPS C:\\ > [uint32]$b = 0xffffffff\r\nPS C:\\ > $b\r\n4294967295\r\n\r\nActual behavior\r\n---------------\r\nPS C:\\> [uint32]$b = 0xffffffff\r\nCannot convert value \"-1\" to type \"System.UInt32\". Error: \"Value was either too large or too small for a UInt32.\"\r\nAt line:1 char:1\r\n+ [uint32]$b = 0xffffffff\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException\r\n + FullyQualifiedErrorId : RuntimeException\r\n \r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\n> $PSVersionTable\r\nPS C:\\> $PSVersionTable\r\n\r\nName Value \r\n---- ----- \r\nPSVersion 5.1.15050.0 \r\nPSEdition Desktop \r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} \r\nBuildVersion 10.0.15050.0 \r\nCLRVersion 4.0.30319.42000 \r\nWSManStackVersion 3.0 \r\nPSRemotingProtocolVersion 2.3 \r\nSerializationVersion 1.1.0.1 \r\n\r\n```\r\n","author":{"url":"https://github.com/viorel-m","@type":"Person","name":"viorel-m"},"datePublished":"2017-03-12T22:17:56Z","url":"https://github.com/PowerShell/PowerShell/issues/3313"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b6d4e48-a6b7-ee77-9232-f936c146c4d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EBE:3257C8:1FBB8A:2B0200:6AFD5057 |
| html-safe-nonce | a8e0386961d98cd31217ac3c38c7bce3be5271fa38b7fce868728fd86aa6cf26 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUJFOjMyNTdDODoxRkJCOEE6MkIwMjAwOjZBRkQ1MDU3IiwidmlzaXRvcl9pZCI6IjYxMDEyMjcyMTg3NDA3OTM0MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f4c21e54005a2aac298856daaa398ffe4001f44342bf38b7ce903eccf9c0c0fa |
| hovercard-subject-tag | issue:213639765 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3313/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e7dd98a8ebd85ceffcc703f2545ebbe64eae090fe49f2c21b5bb334383782bc4/PowerShell/PowerShell/issues/3313 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e7dd98a8ebd85ceffcc703f2545ebbe64eae090fe49f2c21b5bb334383782bc4/PowerShell/PowerShell/issues/3313 |
| og:image:alt | Steps to reproduce Description: I can't make powershell use correctly types like [uint32] or [uint64]. It seems like it always tries to dumb down every number to [int], and does it poorly. The bug ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | viorel-m |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width