Gentlemen,
Some of my favorite things that came with the addition of floating point support are the addition of local variables, custom functions that accept arguments and custom functions that return a value.
I think that it is very limiting that the only data type that is supported for the local variables, arguments and return values are floating point. However, there are lots of cases where a 32-bit integer is much more useful.
I understand that the the Bits2Float(n) and Float2Bits(n) functions can be used as sort of a "C-like" cast, that can allow a float variable to behave integer, but this mechanism is very awkward.
As an example, I'd like to use the local variable, %[1] as an integer:
%[1] = Bits2Float(3)
%[1] = Bits2Float(Float2Bits(%[1])/2)
[/color][/font]
Now I know that with the #DefineLocal I can make this code a little more readable, but it is still tricky:
#DefineLocal ILocal = Float2Bits(%[1])
#DefineLocal ILocalF = %[1]
ILocalF = Bits2Float(3)
ILocalF = Bits2Float(Ilocal/2)
[/color][/font]
This is what I like you guys to think about on future versions of the Fx firmware and the ITrilogi compiler, some sort of limited type definitions. Some thing on this order:
' Declare a local variable that is to function as a signed 32-bit integer
'
#DefineLocal ILocal = (INT32)%[1]
ILocal = 3 ' Assignment of an integer variable to a local var
ILocal = Ilocal / 2 ' Integer math and an assignment to a local var
[/color][/font]
The cast "(INT32)" could clue the compiler that the type of the data stored at %[1] is an integer and should be treated as such.
Floats are nice, but there are a lot of cases where Floats can NOT do the job. Try to represent the integer &h7ffffffffffffff with a float!
If would be even nicer if there was a way to indicate to the compiler the behavior of a custom function so that arguments could be passed to a custom function as an integer and NOT promoted to a float. Think modern programming languages. Some sort of function declaration:
' The following function returns a 32-bit signed intger
' and takes 2 arguments, the first one is an integer and the second is a float
'
INT32 FunctionX(INT32 A, FLOAT B) ' function declaration
for i = 1 to 10
DM32 = FunctionX(i, 3.14159) ' using the function
next
[/color][/font]
The same function declartion would be needed to be repeated in actual custom function, "FunctionX".
I realize that this is probably too big a change to a language like TBASIC to support, but I can always ask.
Gary D.