Liu Hui (fl. 3rd century CE) was a Chinese mathematician and writer who lived in the state of Cao Wei during the Three Kingdoms period (220–280) of China. In 263, he edited and published a book with solutions to mathematical problems presented in the famous Chinese book of mathematics known as The Nine Chapters on the Mathematical Art, in which he was possibly the first mathematician to discover, understand and use negative numbers. He was a descendant of the Marquis of Zi District (菑鄉侯) of the Eastern Han dynasty, whose marquisate is in present-day Zichuan District, Zibo, Shandong. He completed his commentary to the Nine Chapters in the year 263. He probably visited Luoyang, where he measured the sun's shadow.