Title: Bug with bigint multiplication · Issue #21341 · PowerShell/PowerShell · GitHub
Open Graph Title: Bug with bigint multiplication · Issue #21341 · PowerShell/PowerShell
X Title: Bug with bigint multiplication · Issue #21341 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/21341
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug with bigint multiplication","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\n```\r\nWrite-Host \"int: $([int]5 * [double]1.5)\"\r\nWrite-Host \"bigint: $([bigint]5 * [double]1.5)\"\r\n```\r\nprints\r\n```\r\nint: 7.5\r\nbigint: 5\r\n```\r\n\r\nusing c# directly in PS prints the correct result\r\n```\r\nAdd-Type -TypeDefinition @\"\r\nusing System;\r\nnamespace DemoCode\r\n{\r\n public class DemoClass\r\n {\r\n public static void Test()\r\n {\r\n int i = 5;\r\n System.Numerics.BigInteger bi = 5;\r\n double d = 1.5;\r\n\r\n double r = i * d;\r\n Console.WriteLine(\"bigint c#: \" + r.ToString());\r\n }\r\n }\r\n}\r\n\"@\r\n[DemoCode.DemoClass]::Test()\r\n```\r\nprints\r\n```\r\nbigint c#: 7.5\r\n```\r\n\r\nWhy is the multiplication directly in PS truncating the double?\r\nIt doesn't matter if I use 1.1, 1.5 or 1.9, the double gets truncated and then multiplied.\r\n\r\nThis bug happens in PowerShell 74.1 and 5\n\n### Expected behavior\n\n```console\nPS> [bigint]5 * [double]1.5\r\n7.5\n```\n\n\n### Actual behavior\n\n```console\nPS> [bigint]5 * [double]1.5\r\n5\n```\n\n\n### Error details\n\n```console\nThere was no error\n```\n\n\n### Environment data\n\n```powershell\nPS> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.4.1\r\nPSEdition Core\r\nGitCommitId 7.4.1\r\nOS Microsoft Windows 10.0.22631\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/Tragen","@type":"Person","name":"Tragen"},"datePublished":"2024-03-13T20:29:06Z","url":"https://github.com/PowerShell/PowerShell/issues/21341"}
| 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:513ed2dd-a4c2-d6c2-e7ab-245521eb44d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2F0:38CE01:2E0F38:3D5938:6AFD35E8 |
| html-safe-nonce | 214668e5fcc8640f8418f5639735bace8bf916d018917fdbd168504e6a3a1706 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkYwOjM4Q0UwMToyRTBGMzg6M0Q1OTM4OjZBRkQzNUU4IiwidmlzaXRvcl9pZCI6Ijc0MzEzMDk0Nzk5OTMyMjY3MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 66a41ecb45b03718d18bd360fb14f5d101f986026297acf344b58235b54d81ba |
| hovercard-subject-tag | issue:2184833016 |
| 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/21341/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f2f7e6ecf7b9e04faacb98271d68da9851b8555119eccdb1eb98a37663cabb90/PowerShell/PowerShell/issues/21341 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f2f7e6ecf7b9e04faacb98271d68da9851b8555119eccdb1eb98a37663cabb90/PowerShell/PowerShell/issues/21341 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Tragen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| 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 | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width