# Re: square root

From: Joseph Zambon <jbzambon_at_nyahnyahspammersnyahnyah>
Date: Tue, 22 Sep 2009 17:24:44 -0400

Gabrielle,

The problem is that you're assigning the variable on the left hand
side the same as the variable on the right hand side. When you do
that, you'll get the following error:
fatal:Assignment type mismatch, right hand side can't be coerced to
type of left hand side
fatal:Execute: Error occurred at or near line 5

In this case, be sure the variable names you're assigning values to
have different names than the ones used to come up with that value.

In this way, I have no problem using sqrt with an integer...

ncl 0> d2 = 9
ncl 1> d3 = sqrt(d2)
ncl 2> print(d2)
Variable: d2
Type: integer
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 9
ncl 3> print(d3)
Variable: d3
Type: float
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 3

I also am able to arrive at the correct answer with ^0.5...
ncl 0> d4=9
ncl 1> d5=d4^0.5
ncl 2> print(d4)
Variable: d4
Type: integer
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 9
ncl 3> print(d5)
Variable: d5
Type: float
Total Size: 4 bytes
1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 3

-Joe

Joseph B. Zambon
jbzambon_at_ncsu.edu
NC State University
Department of Marine, Earth and Atmospheric Sciences
Jordan 4133

On Sep 22, 2009, at 5:06 PM, Gabrielle Ferreira Pires wrote:

> Hello NCL users!
>
> What am I getting wrong in the following expression?
>
> d2 = ((d2)^(0.5))
>
> obs.: I've already tried to use with or without the parentheses.
>
> d2 is a variable of type integer, so I can't use the sqrt function,
> right?
>
> Thanks!!
>
> Gabrielle Pires
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 22 2009 - 15:24:44 MDT

This archive was generated by hypermail 2.2.0 : Thu Sep 24 2009 - 13:55:09 MDT