poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pkl,std: add `format_f32' and `format_f64' std functions


From: Jose E. Marchesi
Subject: Re: [PATCH] pkl,std: add `format_f32' and `format_f64' std functions
Date: Sun, 08 Jan 2023 13:37:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Hi Jose.
>
> On Sun, Jan 08, 2023 at 12:21:28AM +0100, Jose E. Marchesi wrote:
>> 
>> Hi Mohammad.
>> 
>> > This commit adds two new library functions to create string
>> > representation of single/double-precision floating-point numbers
>> > from uint<32>/uint<64>.
>> 
>> Wouldn't it be better to add support for %f, %e and %g to `format' and
>> `printf' instead of having these library functions?
>> 
>
> Yes, but implementing two new functions was easier :)

Nice try :D

> Are you OK with the following syntax?
>
>   "%f32d"    // float32 in base 10
>   "%f64d"    // float64 in base 10
>
>   // With explicit precision
>   "%f32.7d"
>   "%f64.15d"
>
>   // And other styles
>   "%e32d"
>   "%e64d"
>   "%g32d"
>   "%g64d"
>
> In future we can also support other bases (like "%f32b" or "%f64x").

I think that syntax is ok.  It matches well with the syntax we have for
integral values, and is extensible.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]