www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Type conversions in D

reply Jean Cesar <jeanzonta777 yahoo.com.br> writes:
I once saw an article that talked about type conversions using 
the D language.

Type convert integer to exadecimal, binary, but I'm thinking of 
writing an article in my blog but I do not find the site I saw on 
to know more information of the same type as I did below.

void main()
{
   int a=15;

  writefln("O numero %s em binario é %b", a, a);
}
Feb 21 2017
parent reply Seb <seb wilzba.ch> writes:
On Tuesday, 21 February 2017 at 21:39:37 UTC, Jean Cesar wrote:
 I once saw an article that talked about type conversions using 
 the D language.

 Type convert integer to exadecimal, binary, but I'm thinking of 
 writing an article in my blog but I do not find the site I saw 
 on to know more information of the same type as I did below.

 void main()
 {
   int a=15;

  writefln("O numero %s em binario é %b", a, a);
 }
Note that what you are looking for is a library feature: https://dlang.org/phobos/std_conv.html In fact every type can implement its own specific format handling: https://dlang.org/phobos/std_format.html
Feb 21 2017
parent reply Jean Cesar <jeanzonta777 yahoo.com.br> writes:
On Tuesday, 21 February 2017 at 22:09:11 UTC, Seb wrote:
 On Tuesday, 21 February 2017 at 21:39:37 UTC, Jean Cesar wrote:
 I once saw an article that talked about type conversions using 
 the D language.

 Type convert integer to exadecimal, binary, but I'm thinking 
 of writing an article in my blog but I do not find the site I 
 saw on to know more information of the same type as I did 
 below.

 void main()
 {
   int a=15;

  writefln("O numero %s em binario é %b", a, a);
 }
Note that what you are looking for is a library feature: https://dlang.org/phobos/std_conv.html In fact every type can implement its own specific format handling: https://dlang.org/phobos/std_format.html
I'm not talking about it so I'm seeing what I've seen and I'm looking for things about the integer conversion operators for exa, from exa to integer etc ... I saw this once on the tutorialspoint site but I went there and I can not find any more I know if it was removed.
Feb 21 2017
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/21/2017 02:26 PM, Jean Cesar wrote:
 On Tuesday, 21 February 2017 at 22:09:11 UTC, Seb wrote:
 On Tuesday, 21 February 2017 at 21:39:37 UTC, Jean Cesar wrote:
 I once saw an article that talked about type conversions using the D
 language.

 Type convert integer to exadecimal, binary, but I'm thinking of
 writing an article in my blog but I do not find the site I saw on to
 know more information of the same type as I did below.

 void main()
 {
   int a=15;

  writefln("O numero %s em binario é %b", a, a);
 }
Note that what you are looking for is a library feature: https://dlang.org/phobos/std_conv.html In fact every type can implement its own specific format handling: https://dlang.org/phobos/std_format.html
I'm not talking about it so I'm seeing what I've seen and I'm looking for things about the integer conversion operators for exa, from exa to integer etc ... I saw this once on the tutorialspoint site but I went there and I can not find any more I know if it was removed.
Just for clarification, what you've originally shown is formatting: no type conversion is involved. For type conversions, this is a must read anyway: https://dlang.org/spec/type.html#integer-promotions (And "Usual Arithmetic Conversions" there.) However, I think you're talking about literal syntax: https://dlang.org/spec/lex.html#integerliteral which I had attempted to rephrase here: http://ddili.org/ders/d.en/literals.html#ix_literals.literal Ali
Feb 21 2017