Skip to content

Fix CSS-style #rrggbbaa colors

Jean Abou Samra requested to merge jeanas/lilypond:fix-css-colors into master

This code was shifting by 8 bits (multiplying by 256) instead of 4 (to multiply by 16). In addition, C and C++ apparently have weird promotion rules regarding bitwise operations [1], which got us into oddity and undefined behavior territory (I have not investigated what precisely). Another problem was the division by 256.0, which is incorrect because mapping the range [0, 255] to [0, 1] requires dividing by 255.0.

Fix this by replacing the expression with a simple and correct arithmetic operation where typing is clear.

[1] https://wiki.sei.cmu.edu/confluence/display/c/EXP14-C.+Beware+of+integer+promotion+when+performing+bitwise+operations+on+integer+types+smaller+than+int

Closes #6200 (closed)

Merge request reports