Skip to content

Fix very old lazer replays failing to decode #33969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jul 1, 2025

@bdach bdach requested a review from peppy July 1, 2025 08:21
Comment on lines +300 to +301
// notably this cannot just be `(int)Parsing.ParseFloat(split[0])`, because that can lose information
// (`float` numbers have 24 bits of significand precision, which is not enough to accurately represent every possible value of `int`).
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

claim experimentally backed by

for (int i = int.MinValue; i + 1 != int.MinValue; i++)
{
    if (i % 10000000 == 0)
        Console.WriteLine(i);
    string s = i.ToString();
    float f = float.Parse(s);
    if ((int)f != i)
        throw new InvalidOperationException($"nope (float={(int)f} int={i})");
}

output

Unhandled exception. System.InvalidOperationException: nope (float=-2147483648 int=-2147483647)
   at Program.<Main>$(String[] args) in /Users/bdach/Documents/Work/tools/Sketchpad/Sketchpad/Program.cs:line 8

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

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

👍

@peppy peppy merged commit c845dd0 into ppy:master Jul 1, 2025
9 checks passed
@bdach bdach deleted the old-replays-or-something branch July 1, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants