Using SWAP with numbers
Root / SmileBASIC Bug Reports / [.]
12Me21Created:
DEF TEST A,B SWAP A,B ?B,A END TEST 7,2.3 '7 2I guess this isn't technically a bug, but it's very annoying to deal with. SWAP doesn't actually swap number variables, it just swaps the VALUES. So if you swap a float and an int, the value that was stored in the float will be truncated. This is a problem when using SWAP in functions, because the types of the variables are controlled by the input values. (In the example, replacing 7 with 7.0 or 7# will fix the problem, but that's annoying and you can't trust the user to do that.)