Li-Fan Chen says to YSITD
d = d & (2^517 -1)