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 3-Nov-2024 19:34:13

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

rounding prioblem using ftoi or ftoi with negative float

hello when I use ftoi on this float:

-0.998224

I get

0

when I use ftori on the same float, -0.998224, I get

0

what .pkg can i use from the os3d or scol repository that rounds a negative number between - x.5y  (where x is any number, or y,  or a digit further to the right of y, is more than 0), to  -x -1 , and which will round a positive     x.5y (where x is any number, or y,  or a digit further to the right of y, is more than 0) to x+1

thanks!
-Dan

Offline

#2 3-Nov-2024 19:55:39

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

Re: rounding prioblem using ftoi or ftoi with negative float

i think there is a typo in tools.pkg, which reads

fun ftori(val)=

  if (val >=. 0.0) then

    ftoi (val +. 0.5)

  else

    ftoi (val -. 0.5);;

if i change it to:

fun ftori(val)=

  if (val >=. 0.0) then

    ftoi (val +. 0.5)

  else

    ftoi (val -. 0.5);;

the negative integer rounds (down) correctly for what i want to do in my code

Offline

Board footer

Powered by FluxBB