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
5 changed files
with
38 additions
and
0 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
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
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,24 @@ | ||
#include "RspClamp.h" | ||
|
||
uint16_t clamp16(int32_t Value) | ||
{ | ||
if (Value > 0x7FFF) | ||
{ | ||
return 0x7FFF; | ||
} | ||
if (Value < (int32_t)0xffff8000) | ||
{ | ||
return 0x8000; | ||
} | ||
return (uint16_t)Value; | ||
} | ||
|
||
int64_t clip48(uint64_t Value) | ||
{ | ||
enum : uint64_t | ||
{ | ||
b = 1ull << (48 - 1), | ||
m = b * 2 - 1 | ||
}; | ||
return ((Value & m) ^ b) - b; | ||
} |
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,5 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
uint16_t clamp16(int32_t Value); | ||
int64_t clip48(uint64_t); |