How to use Power on D

Carlos checoimg at gmail.com
Wed Jun 12 17:24:15 PDT 2013


So I have this code I'm working on but I get weird results. What 
am I doing wrong ?

Code :

import std.stdio;
import std.c.stdlib;

void main()
{
foreach (count; 1 .. 16){
	write("Result : ", (2)^(count), " from : ", count, "\n");
	}
}

Prints:

Result : 3 from : 1
Result : 0 from : 2
Result : 1 from : 3
Result : 6 from : 4
Result : 7 from : 5
Result : 4 from : 6
Result : 5 from : 7
Result : 10 from : 8
Result : 11 from : 9
Result : 8 from : 10
Result : 9 from : 11
Result : 14 from : 12
Result : 15 from : 13
Result : 12 from : 14
Result : 13 from : 15

Thank you for your time.


More information about the Digitalmars-d-learn mailing list