-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include(TestBigEndian) | ||
|
||
macro(define_python_endianness_macros) | ||
TEST_BIG_ENDIAN(WORDS_BIGENDIAN) | ||
|
||
# Test for float endianness | ||
try_run(RESULT_VAR COMPILE_VAR | ||
${CMAKE_BINARY_DIR}/check_float_endianness_result | ||
${CMAKE_SOURCE_DIR}/cmake/check_float_endianness.c | ||
) | ||
if(RESULT_VAR EQUAL 1) | ||
message(STATUS "System uses big-endian floating point format") | ||
set(FLOAT_WORDS_BIGENDIAN 1) | ||
else() | ||
message(STATUS "System uses little-endian floating point format") | ||
set(FLOAT_WORDS_BIGENDIAN 0) | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// Test with a known float value (1.0f) | ||
float test = 1.0f; | ||
unsigned char *bytes = (unsigned char*)&test; | ||
|
||
// The float 1.0f has a known IEEE-754 representation | ||
// In big-endian, the first byte would be 0x3F | ||
// In little-endian, the first byte would be 0x00 | ||
if (bytes[0] == 0x3F) { | ||
// Big-endian float | ||
return 1; | ||
} else { | ||
// Little-endian float | ||
return 0; | ||
} | ||
} |