Hi all,

I have an issue with the KAREL SQRT function. I want to CALL a KAREL program in TP, that returns the square root of a number (simple application of the theorem of Pythagoras a²+b²=c²).

This is the code i have in KAREL

```
PROGRAM WURZEL
%COMMENT = 'Wurzel berechnen'
VAR
r_RADICAND : REAL
r_RESULT : REAL -- result value of the SQRT
i_RESULT_REG : INTEGER -- Number of the numeric register
data_type : INTEGER
int_value : INTEGER
real_value : REAL
status : INTEGER
string_value : STRING[80]
BEGIN
-- WURZEL(r_RADICAND, i_RESULT_REG)
-- get the readicand
GET_TPE_PRM(1, data_type, int_value, r_RADICAND, string_value, status)
-- get the register number where the result will be written to
GET_TPE_PRM(2, data_type, i_RESULT_REG, real_value, string_value, status)
-- calculate the square root
r_RESULT=SQRT(r_RADICAND)
-- writes the result to the register number
SET_REAL_REG (i_RESULT_REG,r_RESULT,status)
END WURZEL
```

Display More
And this is a small program to test the result in TP:

When I run the program with a real value in R[74] it all works fine (e.g. R[74]=64.5 --> R[75] will be 8.03319). But as soon as I'll try an integer value like 64, the Karel program writes 0 to R[75]. I tried entering 64.0 but the TP changes it to 64.

Next thing I've tried is calculating the square root with a work around (cause KAREL obviously doesn't know something like a POWER function):

x^{0.5}=exp(0.5*ln(x))

With a real value it works fine as well, but with an integer value like 64 it crashes ROBOGUIDE.

Has anyone of you encountered this problem before, or am I missing some important things, or is my code wrong?

I'm looking ahead to hear from you guys.

Cheers

Joachim