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
def calc_check_digit(digits): | |
digits = [int(i) for i in str(digits)][:-1] | |
odd_pos_list = digits[0::2] # 1st, 3rd, 5th, etc | |
even_pos_list = digits[1::2] # 2nd, 4th, 6th, etc | |
n = (sum(odd_pos_list) * 3) + sum(even_pos_list) | |
rmndr = n % 10 | |
return (10 - rmndr) if rmndr > 0 else 0 |
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
public static byte LOBYTE(ushort a) => | |
(byte)(a & 0xFF); | |
public static byte HIBYTE(ushort a) => | |
(byte)((a >> 8) & 0xFF); | |
public static ushort HIWORD(uint a) => | |
(ushort)((a >> 16) & 0xFFFF); | |
public static ushort LOWORD(uint a) => |
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
#define MIN(A, B) ((A) < (B) ? (A) : (B)) | |
#define MAX(A, B) ((A) > (B) ? (A) : (B)) | |
#define CLAMP(N, LO, HI) (MIN(MAX((LO), (N)), (HI))) |
OlderNewer