Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 7-Oct-2024 16:12:33

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

float multiplciation resulting in 0

hello everyone

I am having a problem with two floats, neither of which is equal to 0.0, being multiplied and resulting in 0.0...

 let _fooS strcatn "derived r from getmyhexcoordinates is: ":: (itoa r)::nil-> string in// this shows -derived r from getmyhexcoordinates is: -100 in log
  let sqrt (3.0)  *. (itof r) -> squaretimesr in 
  let _fooS strcatn "square root of 3 times r is: " :: (ftoa squaretimesr)::nil -> string in // this shows "square root of 3 times r is: 0.000000" in the log

I also tried putting the 3.0 outside of parenthesis to the same result

 let _fooS strcatn "derived r from getmyhexcoordinates is: ":: (itoa r)::nil-> string in// this shows -derived r from getmyhexcoordinates is: -100 in log
  let sqrt 3.0  *. (itof r) -> squaretimesr in 
  let _fooS strcatn "square root of 3 times r is: " :: (ftoa squaretimesr)::nil -> string in // this shows "square root of 3 times r is: 0.000000" in the log

any guidance welcome!
-Dan

Offline

#2 8-Oct-2024 01:35:04

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

Re: float multiplciation resulting in 0

let's say i have a function that once in a while makes a variable , say, x, = 0, how do I handle things so it doesn't get calculated and crash the vm?

thanks!
-Dan

Last edited by hebdemnobad (8-Oct-2024 02:17:07)

Offline

#3 8-Oct-2024 08:17:18

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,148
Website

Re: float multiplciation resulting in 0

Hello hexa numbers can be converted into integer using htoi https://www.openspace3d.com/scoldoc/htoi.html

let _fooS strcatn "derived r from getmyhexcoordinates is: ":: (itoa htoi r)::nil-> string in// this shows -derived r from getmyhexcoordinates is: -100 in log
  let sqrt (3.0  *. (itof htoi r)) -> squaretimesr in 
  let _fooS strcatn "square root of 3 times r is: " :: (ftoa squaretimesr)::nil -> string in // this shows "square root of 3 times r is: 0.000000" in the log

Offline

#4 8-Oct-2024 13:31:30

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

Re: float multiplciation resulting in 0

arkeon wrote:

Hello hexa numbers can be converted into integer using htoi https://www.openspace3d.com/scoldoc/htoi.html

let _fooS strcatn "derived r from getmyhexcoordinates is: ":: (itoa htoi r)::nil-> string in// this shows -derived r from getmyhexcoordinates is: -100 in log
  let sqrt (3.0  *. (itof htoi r)) -> squaretimesr in 
  let _fooS strcatn "square root of 3 times r is: " :: (ftoa squaretimesr)::nil -> string in // this shows "square root of 3 times r is: 0.000000" in the log

The qrs coordinate numbers are integers...or are you saying that scol can convert qrs coordinates in 3 axis space to xy coordinates in 2 axis space?

Offline

#5 9-Oct-2024 07:58:11

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,148
Website

Re: float multiplciation resulting in 0

if this is intergers just remove htoi

yes you can concert 3D coords into 2D coords with projection functions, but I miss some infos to understand the purpose of the code

Offline

#6 9-Oct-2024 13:57:32

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

Re: float multiplciation resulting in 0

arkeon wrote:

if this is intergers just remove htoi

yes you can concert 3D coords into 2D coords with projection functions, but I miss some infos to understand the purpose of the code


thanks I will play around with that although as per my other thread i've figured out how to translate three axis coordinates of the system...

Offline

Board footer

Powered by FluxBB