By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
DECLARE @TestVal AS float = 8.88;
SELECT flt = @TestVal
, xml = (SELECT Value = @TestVal FOR XML PATH(''), TYPE)
, fmt17 = FORMAT(@TestVal, 'G17')
, fmt = FORMAT(@TestVal, 'G')
, cst = CAST(@TestVal AS nvarchar(50))
, fmt17_roundtrip = CAST(FORMAT(@TestVal, 'G17') AS float)
, fmt_roundtrip = CAST(FORMAT(@TestVal, 'G') AS float)
, cst_roundtrip = CAST(CAST(@TestVal AS nvarchar(50)) AS float)
;
flt | xml | fmt17 | fmt | cst | fmt17_roundtrip | fmt_roundtrip | cst_roundtrip |
---|---|---|---|---|---|---|---|
8.88 | <Value>8.880000000000001e+000</Value> | 8.8800000000000008 | 8.88 | 8.88 | 8.88 | 8.88 | 8.88 |