Skip to content

[raymath] Oddities with division #4687

Closed
@redbullmarky

Description

@redbullmarky

Issue description

Using raylib 5.5 (installed via vcpkg), I came across unexpected behaviour with one of the new C++ Vector2 operators.

Code Example

Vector2 v1 = { 5.f, 5.f };
Vector2 v2 = { 5.f, 5.f };
Vector2 v3 = { 5.f, 5.f };
Vector2 v4 = { 5.f, 5.f };

v1 = v1 / 2.f;
v2 /= 2.f;

v3 *= 2.f;
v4 = v4 * 2.f;

Essentially the issue is the difference between the results produced for v1 & v2. I added v3 and v4 examples just for comparison etc.

But the results:

v1 -> 2.5, 2.5  <-- ok
v2 -> 10, 10   <-- not right?
v3 -> 10, 10   <-- ok
v4 -> 10, 10   <-- ok

Looking at the code in raymath.h, it does seem like /= is identical to *= operator logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions