falling down auto type cast float to integer
Piles of Wires
Junior Member
Odd thing...
an_Int = a_Float*255.0
an_Int = 255.0
Compiler says:
ERROR: File.axs(1): C10512: Cannot convert type [FLOAT] to [INTEGER]
ERROR: File.axs(2): C10533: Illegal assignment statement
WARNING: File.axs(2): C10571: Converting type [FLOAT] to [INTEGER]
So my question is: Why does it fail on the first conversion not the second? and how do I fix it?
an_Int = a_Float*255.0
an_Int = 255.0
Compiler says:
ERROR: File.axs(1): C10512: Cannot convert type [FLOAT] to [INTEGER]
ERROR: File.axs(2): C10533: Illegal assignment statement
WARNING: File.axs(2): C10571: Converting type [FLOAT] to [INTEGER]
So my question is: Why does it fail on the first conversion not the second? and how do I fix it?
Comments
-
The compiler will not test if the result of the operation is a full number (i.e. 255.0). The compiler just sees in both operations a pass of a Float value into an Integer, which is not allowed.Piles of Wires wrote:Odd thing...
an_Int = a_Float*255.0
an_Int = 255.0
Compiler says:
ERROR: File.axs(1): C10512: Cannot convert type [FLOAT] to [INTEGER]
ERROR: File.axs(2): C10533: Illegal assignment statement
WARNING: File.axs(2): C10571: Converting type [FLOAT] to [INTEGER]
So my question is: Why? and how do I fix it?
A TYPE_CAST() will "cut off" the values after the commaan_Int = TYPE_CAST(a_Float*255.0) an_Int = TYPE_CAST(255.0) // an_Int now is 255
-
Thanks alot.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums