I thought int() AKA
val() was for converting strings to integers, not floats to integers
such as...
b = int(a$)
...or...
b = val(a$)
...in AGK
with the opposite being converting integers to strings with
str() as in ...
a$=str(b)
and if you want to round a float to the nearest integer then use the
round() command...
b = round(a#)
or round it up to the next integer with the
ceil() command...
b = ceil(a#)
or convert the float to an integer without rounding with the
trunc() command...
b = trunc(a#)
Quote: "
'val()' generally deals with string to integer and another detail to be aware of there is the distinction between integer and float. While in DBPro, you could use 'val()' to retrieve a numerical value for either an integer or a float, in AGK/S, you need to use 'val()' for integers and 'valfloat()' for floats."
My memory is not what it used to be, but historically for me
int() was used for converting stings to integers and
str() to convert the integers to strings.
I have trouble remembering the rest because I rarely need to convert integers to floats and vice versa.
I was not aware of the valfloat(), but I probably would have just converted the float to an integer, and then use val().
Nice to know it is there though as that would give better results of course if you need retain the values past the decimal point.
I rarely need to use floats for things that will be converted to strings for display, so I probably have used the valfloat() before, but I just don't remember it.
Flip flopping between languages, I usually end up a documentation junkie having to refer to the docs a lot as so many languages are so similar but also very different.
Sometimes those subtle differences ruin any convenience of the similarities for me, as I get the commands all mixed up all the time.
PHP puts the $ in front of the variable name for a string where AppGameKit puts it behind, and that was hard for me to get used to. (I prefer the AppGameKit way for that)
Most of the modern languages are alike enough to remember all the commonly used commands and structure though, thanks to C and a few others.
Languages like PHP really irritate me though having to put those stupid semicolons at the end of every line. (I still forget to do that all the time)
Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1