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 class Date_My { | |
private final int value; | |
public Date_My(int year, int month, int day){ | |
value = year*512 + month*32 + day; | |
// value = y * 2^9 + m * 2^5+ d; | |
} | |
public int month(){ | |
return (value / 32) % 16; | |
// 除以32后,剩下 y*2^4 + m(d消掉了,2^4 = 2^9 / 2^5),接着再用16(即2^4)取余,得month | |
} |