You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get-Random unexpectedly outputs [double] values with various integer types #3598
The existing documentationpartially contradicts current behavior:
Enter a 32-bit integer or a double-precision floating-point number, or an object that can be converted to an integer or double
If we assume that "to an integer" means to an [int32], then certainly the smaller integer types would qualify for that conversion - but that's not what's happening currently.
Under the same assumption, you could argue that the larger integer types only fit into [double], so they should be treated as that, which is true for [uint64], but not for [int64].
I think that a change is warranted from a common-sense standpoint, and that the change falls into bucket 3 - unlikely grey area.
Michael Klement (@mklement0) I mean only that the code make this explicity and it is not bug.
Is "Expected behavior" that you want to get precisely or you want to get int32 for small "integers"?
Ilya (@iSazonov): That's fine, as long as there's agreement that the behavior is counter-intuitive (which is what I meant by "unexpected").
I think getting the precise type back makes sense, but I'm not sure I'm aware of all the ramifications.
(As an aside: It's open to debate whether the source code reflects deliberate intent to treat the less common integer types not explicitly mentioned as [double], or whether that was a mere oversight.)
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Activity
iSazonov commentedon Apr 19, 2017
With code side it is "by design" not "unexpectedly". So should we change the design?
mklement0 commentedon Apr 20, 2017
Ilya (@iSazonov):
The existing documentation partially contradicts current behavior:
If we assume that "to an integer" means to an
[int32], then certainly the smaller integer types would qualify for that conversion - but that's not what's happening currently.Under the same assumption, you could argue that the larger integer types only fit into
[double], so they should be treated as that, which is true for[uint64], but not for[int64].I think that a change is warranted from a common-sense standpoint, and that the change falls into bucket 3 - unlikely grey area.
iSazonov commentedon Apr 20, 2017
Michael Klement (@mklement0) I mean only that the code make this explicity and it is not bug.
Is "Expected behavior" that you want to get precisely or you want to get int32 for small "integers"?
mklement0 commentedon Apr 20, 2017
Ilya (@iSazonov): That's fine, as long as there's agreement that the behavior is counter-intuitive (which is what I meant by "unexpected").
I think getting the precise type back makes sense, but I'm not sure I'm aware of all the ramifications.
(As an aside: It's open to debate whether the source code reflects deliberate intent to treat the less common integer types not explicitly mentioned as
[double], or whether that was a mere oversight.)microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.