## digitalmars.D.learn - exponent operator/library function

• Michael P. (3/3) Aug 04 2008 Quick question: What do you have to use to do something like, 10 to the ...
• BCS (2/9) Aug 04 2008 iirc its.math.pow(base,exp);
• Michael P. (8/21) Aug 04 2008 Unfortunately, those didn't work( because of type issues). So I made my ...
• BCS (5/8) Aug 04 2008 line 125: for ( int i = arrayToConvert.length; i > 0; i-- )
• Jarrett Billingsley (6/14) Aug 04 2008 You mean i >= 0, I suppose. ;)
• BCS (10/33) Aug 04 2008 Keep (gently) needling me on that. I need to do better.
• Jarrett Billingsley (11/17) Aug 04 2008 cast(int)std.math.pow(10, j)
• Michael P. (5/30) Aug 05 2008 Oh. I just thought it dynamically allocated memory for each new element.
Michael P. <baseball.mjp gmail.com> writes:
```Quick question: What do you have to use to do something like, 10 to the power
of 3? Something in std.math, a built-in operator?
That's all.

-Michael P.
```
Aug 04 2008
```Reply to Michael P.,

Quick question: What do you have to use to do something like, 10 to
the power of 3? Something in std.math, a built-in operator?

That's all.

-Michael P.

iirc its.math.pow(base,exp);
```
Aug 04 2008
Michael P. <baseball.mjp gmail.com> writes:
```BCS Wrote:

Quick question: What do you have to use to do something like, 10 to
the power of 3? Something in std.math, a built-in operator?

That's all.

-Michael P.

iirc its.math.pow(base,exp);

Unfortunately, those didn't work( because of type issues). So I made my own
integer one. :)
Anyways, somewhat unrelated question: I have attached a file that includes a
simple program that I've made for keeping the brain fit, with memory. I've also
Anyways, everything is compiling fine, but I get an ArrayOutOfBounds error on
line 125 or something.
Okay, it's function createArray, which is called by memoryTest. Line 114, 115.
The file is attached.
Does anyone know I'm getting these array errors?

-Michael P.
```
Aug 04 2008
```Reply to Michael P.,

Anyways, everything is compiling fine, but I get an ArrayOutOfBounds
error on line 125 or something.

line 125:	for ( int i = arrayToConvert.length; i > 0; i-- )

that should be:

for ( int i = arrayToConvert.length - 1; i > 0; i-- )

this is because arr[arr.length] is the elemant after the last element.
```
Aug 04 2008
"Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
```"BCS" <ao pathlink.com> wrote in message
news:55391cb32ff418cac458bee9a3c8 news.digitalmars.com...

Anyways, everything is compiling fine, but I get an ArrayOutOfBounds
error on line 125 or something.

line 125: for ( int i = arrayToConvert.length; i > 0; i-- )

that should be:

for ( int i = arrayToConvert.length - 1; i > 0; i-- )

You mean i >= 0, I suppose.  ;)

this is because arr[arr.length] is the elemant after the last element.

No offense BCS, but for someone so well-spoken and intelligent, I'm kind of
shocked at how poor/inconsistent your spelling is.  "elemant" and "element"
in the same sentence?
```
Aug 04 2008
```Reply to Jarrett,

"BCS" <ao pathlink.com> wrote in message
news:55391cb32ff418cac458bee9a3c8 news.digitalmars.com...

Anyways, everything is compiling fine, but I get an ArrayOutOfBounds
error on line 125 or something.

line 125: for ( int i = arrayToConvert.length; i > 0; i-- )

that should be:

for ( int i = arrayToConvert.length - 1; i > 0; i-- )

You mean i >= 0, I suppose.  ;)

that as well

this is because arr[arr.length] is the elemant after the last
element.

No offense BCS, but for someone so well-spoken and intelligent, I'm
kind of shocked at how poor/inconsistent your spelling is.  "elemant"
and "element" in the same sentence?

Keep (gently) needling me on that. I need to do better.

OTOH I have on occasion wondered if I'm borderline dyslexic (My mind just
doesn't seem to "see" spelling errors). I've never bothered to get tested
so I can't claim it as a reason and even if I did get tested I can't claim
it as an excuse*.

Really what I need to do is figure out how to get a spell checker plugged

* there is a fun debate in that fine distinction
```
Aug 04 2008
"Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
```"Michael P." <baseball.mjp gmail.com> wrote in message
news:g77tc7\$2fkr\$1 digitalmars.com...

Unfortunately, those didn't work( because of type issues). So I made my
own integer one. :)

cast(int)std.math.pow(10, j)

...

Okay, it's function createArray, which is called by memoryTest. Line 114,
115.
The file is attached.
Does anyone know I'm getting these array errors?

int[] memoryList;

for ( int i = 0; i < lengthOfList; i++ )
{
memoryList[i] = rand() % 10;
...

Maaaaybe you can see it now.

Hint: how long is memoryList?
```
Aug 04 2008
Michael P. <baseball.mjp gmail.com> writes:
```Jarrett Billingsley Wrote:

"Michael P." <baseball.mjp gmail.com> wrote in message
news:g77tc7\$2fkr\$1 digitalmars.com...

Unfortunately, those didn't work( because of type issues). So I made my
own integer one. :)

cast(int)std.math.pow(10, j)

Okay, it's function createArray, which is called by memoryTest. Line 114,
115.
The file is attached.
Does anyone know I'm getting these array errors?

int[] memoryList;

for ( int i = 0; i < lengthOfList; i++ )
{
memoryList[i] = rand() % 10;
...

Maaaaybe you can see it now.

Hint: how long is memoryList?

Oh. I just thought it dynamically allocated memory for each new element.
Anyways, I put memoryList.length = lengthOfList  above the for statement.
Anyways, thanks for the help. :)
-Michael P.
```
Aug 05 2008