unhuman Posted July 21, 2021 Share Posted July 21, 2021 Messing around with TI Basic for the Mouse Maze competition... And, running out of memory. How many bytes are there used in a number? Seems bigger than 4 bytes... 1 Quote Link to comment Share on other sites More sharing options...
GDMike Posted July 21, 2021 Share Posted July 21, 2021 Probably pointers and tokens are used when lines are created in basic. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted July 21, 2021 Share Posted July 21, 2021 Numbers in the stored program are represented as text, leading with token >C8 (unquoted string) and the length of the number (string). 10 ALPHA=1492 The number 1492 is represented in memory as >C8 >04 >31 >34 >39 >32 This, by the way, also includes line numbers in the program (like GOSUB 32760,) which is why I always number my programs by 1 starting at 1. TIdBiT makes it easy to do this, or you can use the RESEQUENCE command. (NOPE: line numbers are crunched as >C9 "line number" followed by two bytes. The line number 32767 is represented as >C9 >7F >FF. This has caused so many things in my life to no longer make sense.) 3 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted July 21, 2021 Share Posted July 21, 2021 Now, if you are talking about variables, the length of the variable name is significant and takes up space in both the variable table and the stored program. Numbers are represented in the value stack in RADIX 100 format, which consumes eight bytes. 3 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted July 21, 2021 Share Posted July 21, 2021 1 hour ago, unhuman said: Messing around with TI Basic for the Mouse Maze competition... And, running out of memory. How many bytes are there used in a number? Seems bigger than 4 bytes... All Numbers are 8 bytes in Radix 100 and all Strings are at least 2 bytes, byte 1 is length of string up to 255 and string 1 to 255 bytes. Program lines are 2 bytes for programs line, 2 bytes for address of line, then 1 byte for length of line and the XB program line. So for example: 100 ! TEST would be 12 bytes in total, the extra byte is a >C8 token before the spaceTEST to indicated a string. 5 Quote Link to comment Share on other sites More sharing options...
unhuman Posted July 21, 2021 Author Share Posted July 21, 2021 This is super helpful. I think I can leverage this to help me fit more into memory. Thanks so much! 1 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted July 21, 2021 Share Posted July 21, 2021 Arrays can burn a lot of memory, so take care that the DIM is no larger than necessary. As a side note, line numbers don't matter, so : 1 REM 2 REM 3 REM takes the same memory as : 30001 REM 30002 REM 30003 REM 2 Quote Link to comment Share on other sites More sharing options...
+mizapf Posted July 21, 2021 Share Posted July 21, 2021 Yes, line numbers are stored as signed integer numbers, so they may not exceed 32767. 2 Quote Link to comment Share on other sites More sharing options...
moulinaie Posted July 23, 2021 Share Posted July 23, 2021 On 7/21/2021 at 4:17 PM, senior_falcon said: Arrays can burn a lot of memory, so take care that the DIM is no larger than necessary. Yes! There are no integers in TI BASIC... Take care of the Option Base, if you want to store a matrix of 5 colums by 3 lines and that you declare: DIM MAT(5,3) You expect to have 5×3 = 15 numbers... But if you let Option Base 0, indexes start at zero. So you'll have 6×4 = 24 numbers (9 extra numbers consuming 9×8 = 72 bytes!). Guillaume. 5 Quote Link to comment Share on other sites More sharing options...
matthew180 Posted July 24, 2021 Share Posted July 24, 2021 Is there any BASIC dialect on the 99/4A that does *not* use the floating-point for all numbers? Quote Link to comment Share on other sites More sharing options...
Stuart Posted July 24, 2021 Share Posted July 24, 2021 (edited) 8 hours ago, matthew180 said: Is there any BASIC dialect on the 99/4A that does *not* use the floating-point for all numbers? Yes, Cortex BASIC. From the manual: "If a number can be represented in a 16-bit twos complement form, it is stored in integer format." Which is only partially true, as some mathematical operators convert the value to floating point even though the result is an integer. So: A=2 <--- stored as integer A=A*2 <--- result stored as integer B=2 <--- stored as integer B=B^2 <--- result stored as floating point Edited July 24, 2021 by Stuart 5 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.