add max-diff and fix bug
ver 0.12: add zashquar magnitude & preserve values