Re: Concatenates int

2014-07-10 Thread sigod via Digitalmars-d-learn
On Thursday, 10 July 2014 at 17:30:17 UTC, Sean Campbell wrote: if I need to Concatenate ints I'l just use a recursive pow based on length int ConcatInt(int[] anint){ int total = 0; for(int i=0;i With `foreach_reverse` it looks a little better: ```d int concat_ints(int[] ints)

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
On Thursday, 10 July 2014 at 15:51:11 UTC, Olivier Pisano wrote: Hello, I may have not understood what you actually want to do, but aren't std.bitmanip.peek or std.bitmanip.read what you are looking for ? http://dlang.org/phobos/std_bitmanip.html#.peek std.bitmanip.peek and std.bitmanip.read

Re: Concatenates int

2014-07-10 Thread Yota via Digitalmars-d-learn
On Thursday, 10 July 2014 at 15:14:21 UTC, Sean Campbell wrote: On Thursday, 10 July 2014 at 13:51:22 UTC, Rikki Cattermole wrote: On 11/07/2014 1:18 a.m., Sean Campbell wrote: perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and c

Re: Concatenates int

2014-07-10 Thread via Digitalmars-d-learn
On Thursday, 10 July 2014 at 13:51:22 UTC, Rikki Cattermole wrote: On 11/07/2014 1:18 a.m., Sean Campbell wrote: perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again. Small hack I u

Re: Concatenates int

2014-07-10 Thread Olivier Pisano via Digitalmars-d-learn
Hello, I may have not understood what you actually want to do, but aren't std.bitmanip.peek or std.bitmanip.read what you are looking for ? http://dlang.org/phobos/std_bitmanip.html#.peek

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
On Thursday, 10 July 2014 at 13:51:22 UTC, Rikki Cattermole wrote: On 11/07/2014 1:18 a.m., Sean Campbell wrote: perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again. Small hack I u

Re: Concatenates int

2014-07-10 Thread Rikki Cattermole via Digitalmars-d-learn
On 11/07/2014 1:18 a.m., Sean Campbell wrote: perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again. Small hack I use in Dakka: union RawConvTypes(T) { T value; ubyte[T

Re: Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
perhaps I'd better state what I'm doing. i have an array of 4 bytes and a want to convert them to a 32 bit int and convert the 32 bit int back into a 4 bytes again.

Re: Concatenates int

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 02:22 PM, Rikki Cattermole wrote: > On 11/07/2014 12:11 a.m., Sean Campbell wrote: >> i have the ints 4, 7, 0 and 1 how can i Concatenate them into four >> thousand seven hundred and one. > > If we talking at compile time definition: > > int myint = 4_7_0_1; > > Would work. > Howev

Re: Concatenates int

2014-07-10 Thread bearophile via Digitalmars-d-learn
Rikki Cattermole: int myint = to!int("4" ~ "7" ~ "0" ~ "1"); And to concatenate them there is "join" (joiner is not yet usable here, because to!() doesn't yet accept a lazy input, unfortunately). Now they are not strings, and the positions of 10^ doesn't change then: int myint = (1000

Re: Concatenates int

2014-07-10 Thread Rikki Cattermole via Digitalmars-d-learn
On 11/07/2014 12:11 a.m., Sean Campbell wrote: i have the ints 4, 7, 0 and 1 how can i Concatenate them into four thousand seven hundred and one. If we talking at compile time definition: int myint = 4_7_0_1; Would work. However I'll assume its at runtime you really want this. I.e. convertin

Concatenates int

2014-07-10 Thread Sean Campbell via Digitalmars-d-learn
i have the ints 4, 7, 0 and 1 how can i Concatenate them into four thousand seven hundred and one.