Repository navigation
Request for clarification on variable typing and explicit string-to-numeric conversion #32
Replies: 13 comments 7 replies
|
you can try to convert is to be sure: To test, use something like : typeof(variable) return 1 for int, 2 for float and 3 for string Not sure if any of these help... |
|
Clarification on n = float(s) # string → floating-point number |
|
Very helpful comments, thank you very much. |
|
You are very welcome. |
|
I really appreciate you noting that, thank you! I had noticed it as well. I went ahead and wrote a few different sorting algorithms in BASIC-256 to test them, and Shellsort pleasantly surprised me with how fast it runs! |
|
I’ll take that as a compliment! |
|
Certainly, just help me find the benchmark. I could not find anything in the examples. |
|
If you have a directory TestSuite, it should be in there. If you don’t have a TestSuite directory let me know what architecture an OS you are on so I can check. Thanks. |
|
I am on Linux Mint (Cinnamon). I found the test suite folder - it was outside the examples folder. I see many programs there, which would you like me to run? |
|
There should be a benchmark.kbs (maybe in it’s own folder?) |
. text output (LOCATE and one character) - 17539ms
|
|
Thanks. Can I get the exact cpu you have? I am making an excel with benchmark data and currently have RPi4, Apple M1, AMD Ryzen 9 5900X |
|
BTW, there is a Discord channel if you would prefer to chat there.... ( see basics256.org on the Community tab) |
Uh oh!
There was an error while loading. Please reload this page.
I have written a program of about 2,500 lines performing various univariate statistical calculations (I call it DESCSTAT). In it, I have implemented several sorting algorithms, with Shellsort being the easiest to implement and, incidentally, among the fastest.
However, I find the lack of explicit variable typing quite confusing. While being able to mix numeric and string variables in the same expression can occasionally be convenient, my sorting routines initially failed because the sample data (read from a text file) was being treated and sorted as strings.
In addition, since BASIC-256 lacks a standard val() function, the only way I have found to ensure a variable is treated as numeric is to write something like:
x_numeric = y_ambivalent + 0Is there an option or setting to enable strict variable typing or explicit numeric enforcement that I might be missing?
All reactions