Skip to content

AboutNumbers wrong types #474

Description

@magoerlich

https://github.com/vexx32/PSKoans/blob/1317701a7d2bf6ca7efff0eb21d3a3d0478740e9/PSKoans/Koans/Introduction/AboutNumbers.Koans.ps1#L94-L99

Is this part correct about numbers getting converted to longs?

Because no matter, what I try for me it's always a double

Code:

$BigValue = [int]::MaxValue + 200
$BigValue | Should -BeOfType [long]
$BigValue | Should -BeGreaterThan $MaxValue

Output:

Expected the value to have type [long] or any of its subtypes, but got 2147483847 with type [double].

Starting with a short and increasing it to >MaxValue behaves the same:

~\PSKoans
❯ $int = [int]::MaxValue

~\PSKoans
❯ $int.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Int32                                    System.ValueType


~\PSKoans
❯ $int += 100

~\PSKoans
❯ $int.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Double                                   System.ValueType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions