[cfe-dev] Integer and Float type definitions with respect to bits number
Mehmet Erol Sanliturk
m.e.sanliturk at gmail.com
Mon Nov 11 10:38:35 PST 2013
On Mon, Nov 11, 2013 at 1:13 PM, Paul A. Bristow <pbristow at hetp.u-net.com>wrote:
>
>
> *From:* cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] *On
> Behalf Of *Mehmet Erol Sanliturk
> *Sent:* Sunday, November 10, 2013 3:38 PM
> *To:* cfe-dev at cs.uiuc.edu
> *Subject:* [cfe-dev] Integer and Float type definitions with respect to
> bits number
>
>
>
>
> Dears All ,
>
>
> It seems that , in Clang , there is no a type system like the following :
>
>
> Integer_8_Bits_Positive
> Integer_8_Bits_Signed
>
>
>
> Integer_16_Bits_Positive
> Integer_16_Bits_Signed
>
>
>
> Integer_32_Bits_Positive
> Integer_32_Bits_Signed
>
>
> Integer_64_Bits_Positive
> Integer_64_Bits_Signed
>
>
>
>
> Float_48_Bits
> Float_64_Bits
> Float_80_Bits
> Float_128_Bits
>
>
> The following are defined with respect to above types AND Operating System
> ,
> Processor requirements to enable to compile the SAME sources for different
> environments :
>
> Integer_Default_Bits_Positive
> Integer_Default_Bits_Signed
>
> Float_Default_Bits
>
>
> The existing definitions ( long , long long , etc. ) are very ambiguous and
> depending on the platform without clearly showing exact bits number .
>
> Is there a possibility to include definitions such as above into Clang
> or , if there exist such a definition , what is its name ?
>
> There is a proposal to add **optional** floating-point definitions
> (adding to existing integer like int32_t) to the next version of the C and
> C++ standards:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3626.pdf
>
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1703.pdf
>
> This will at least standardise the names of **specified-width** typedefs.
>
> Of course some typedefs may require compiler support,
>
> or a multiprecision library like
>
>
> http://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/index.html
>
> which now also has experimental cpp_bin_float types
>
> https://svn.boost.org/svn/boost/sandbox/multiprecision.cpp_bin_float/
>
> that can emulate various binary layouts.
>
> HTH
>
>
>
> Paul
>
>
>
> ---
>
> Paul A. Bristow,
>
> Prizet Farmhouse, Kendal LA8 8AB UK
>
> +44 1539 561830 07714330204
>
> pbristow at hetp.u-net.com
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Having standard names are important to prevent ambiguity in programs .
This is especially important for multiple platform programming ( ( 32-bits
, 64-bits ) x ( operating systems , processors ) x different compilers )
and maintaining programs over time : Many years ago , "int" was two-bytes ,
but now it is very rare , and conversion of such programs are very
difficult .
Another problem is occurring in file records : If variable types are not
specified by bit-sizes , to use the same file in a file server by different
bit-size operating systems are becoming a very difficult or error prone
task .
To solve such problems , it is important to have variable kinds specified
by bit-numbers .
To supply such definitions in compiler libraries is a more lasting and
error-free approach for the users . Over time , missing parts may be
completed with new bit-sized type definitions instead of definitions like (
long .. , long long ... , long long long ... ) .
Thank you very much .
Mehmet Erol Sanliturk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131111/636acca3/attachment.html>
More information about the cfe-dev
mailing list