Skip to content
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

glm_vec4_round #1223

Open
gottfriedleibniz opened this issue Jan 17, 2024 · 0 comments
Open

glm_vec4_round #1223

gottfriedleibniz opened this issue Jan 17, 2024 · 0 comments

Comments

@gottfriedleibniz
Copy link

glm_vec4_round without SSE41 (e.g., -DGLM_FORCE_SSE2 -DGLM_FORCE_DEFAULT_ALIGNED_GENTYPES) does not properly handle values outside of +/-2^23 (i.e., no fractional part in the float).

For example:

#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <iostream>

int main(void) {
    glm::vec4 v(8388609.f, 8428605.f, 9988605.f, 10388605.f);
    std::cout << "Expected: " << glm::to_string(v) << std::endl;
    std::cout << "Actual:   " << glm::to_string(glm::floor(v)) << std::endl;
    return 0;
}

// └> g++ -O3 -march=native -I${GLM_PATH} -DGLM_FORCE_SSE2 -DGLM_FORCE_DEFAULT_ALIGNED_GENTYPES round.cpp
// └> ./a.out
// Expected: vec4(8388609.000000, 8428605.000000, 9988605.000000, 10388605.000000)
// Actual:   vec4(8388608.000000, 8428604.000000, 9988604.000000, 10388604.000000)

// └> g++ -O3 -march=native -I${GLM_PATH} -DGLM_FORCE_AVX2 -DGLM_FORCE_DEFAULT_ALIGNED_GENTYPES round.cpp
// └> ./a.out
// Expected: vec4(8388609.000000, 8428605.000000, 9988605.000000, 10388605.000000)
// Actual:   vec4(8388609.000000, 8428605.000000, 9988605.000000, 10388605.000000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants