Skip to content

GTA3 floating point math increments at 0.0625 at a time #221

Description

@KyonkoYuuki

This is a really weird issue. I was debugging why some code wasn't working and made this simple counter CLEO script

{$CLEO .cs}
0@ = 0.0
while true
    wait 500
    0@ += 0.1
    0AD1: show_formatted_text_highpriority "%.6f" time 500 0@
end

One would expect it to go up like [0.1, 0.2, 0.3, 0.4, 0.5]

But instead, it goes up like [0.0625, 0.1250, 0.1875, 0.25, 0.3125]

Adding different values like between 0.0-0.6 causes 0@ to not change,
while adding something like 0.2 causes it to go more like [0.1875, 0.3125, 0.5625], as if it was rounding to the nearest floating point divisible by 0.625. I'm not sure if this is a Sanny Builder thing or GTA3 thing, but it does work as expected for VC and SA.

Setting values like 0@ = 0.3 does the same thing as well, where this rounds down to 0.25

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions