Indicating a penny or pence, is the initial letter of the Latin denarius a silver coin equal to 8 ¾d. during the commonwealth of Rome, but in the Middle Ages about equivalent to our penny. The word was used by the Romans for money in general.
stands for 500, which is half ¥, a form of m or M, which stands for mille.
Source: Dictionary of Phrase and Fable, E. Cobham Brewer, 1894