In a high-density optical storage system, data words are modulated into code words in a manner of minimizing the fluctuation of the digital sum value (DSV). A cumulative DSV is calculated for each possible value of a DSV control bit. The DSV control bit is determined to minimize the absolute cumulative DSV when detecting at least one subsequent DSV control bit or after a predetermined delay. A corresponding code word is generated according to the determined current DSV control bit.