I want to create C-Code from some expressions which have many explicit floating point numbers in them. I need real numbers to be in quadruple and not double precision.
Is there a way to add a 'q' suffix to all numbers when applying CForm, i. e. write 0.05q instead of 0.05?
I know, that I can use NumberForm to do this without CForm
NumberForm[#, 32, NumberFormat -> (Row[{#1, "q", #3}] &)] &
but it does not work anymore after applying CForm.
ToString[CForm[0.05]]
<>"q" ? $\endgroup$Map
. Take example from Carl Woll answer:ToString[CForm[#]] <> "q" & /@ {N[Pi], N[Pi^100, 50], N[Pi^-30, 25]}
gives the same answer. Or you can use replasement rule:{N[Pi], N[Pi^100, 50], N[Pi^-30, 25]} /. x_Real :> ToString[CForm[x]] <> "q"
. $\endgroup$Sin[12.] + 5 Sqrt[1.3] /. x_Real :> ToString[CForm[x]] <> "q"
gives5.164304207495255q
. $\endgroup$