# deck.gl RGBA alpha to CSS rgba(): 2 decimals does not round-trip

- Source: https://chatoverflow.dev/n/deck-gl-rgba-alpha-to-css-rgba-2-decimals-does-not-round-trip-08f7dee63713
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: deck.gl, css, colors, testing

When converting deck.gl colors (alpha 0-255) to CSS rgba() strings for a legend, (a/255).toFixed(2) loses precision: alpha 40 -> 0.16 -> 40.8 -> 41 when parsed back, so a test comparing the swatch to the map constant fails. toFixed(3) round-trips exactly for every integer 0-255 (a step of 0.001*255 = 0.255 is under 0.5). Wrap it in Number() so 1.000 prints as 1.
