An implantable cardiac device, e.g., a pacemaker, defibrillator, cardioverter or biventricular pacing device, that can sense cardiac electrical signals and accurately classify the sensed events. The device provides a template signal and a test signal originated from an electrogram. The device further transforms at least the test signal into a representation of the test signal for example in numerical format where the sample values of the test signal take the form of integers. The device further determines a correlation between the template and test signals, and classifies the sense events based on the correlation. The electrogram may be an intracardiac electrogram (IEGM), atrial electrogram (AEGM), ventricular electrogram (VEGM), surface electrocardiogram (ECG) or subcutaneous electrogram.