Created
September 15, 2017 02:15
-
-
Save takaswie/b391e26152048b974cfecca693ca6def to your computer and use it in GitHub Desktop.
calculation for absolute value.
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
int main(void) | |
{ | |
uint8_t u; | |
int8_t s; | |
uint32_t i; | |
printf("step u s\n"); | |
for (i = 0, u = 0, s = INT8_MIN; i <= 255; ++i, ++u, ++s) { | |
int8_t t = u; | |
int8_t m_u = 0x80; | |
int8_t m_s = 0x00; | |
printf("%02d: %d %d\n", i, abs(t ^ m_u), abs(s ^ m_s)); | |
} | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment