Page 2 of 2
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 5:28 pm
by richmond62
Indeed.
The 'advantage' with Fortran and its ilk was that variables were numeric, and strings were strings, do if one put 'A' into a string constant, say $X, the machine would interpret that as a letter, and if it were put into a variable it would be interpreted as a number.
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 7:18 pm
by dunbarx
Richmond.
and if it were put into a variable it would be interpreted as a number.
Long time since I wrote any Fortran, but are you saying Fortran would return "true" with (pseudo):
Code: Select all
REAL :: tVar
if tVar = C then answer (C-5) = 7
Craig
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 7:27 pm
by dunbarx
Richmond.
Are you still trying to use 0-F as a suite of integers in LC? I am sure you can create a gadget that translates those sixteen chars into numbers, and proceed from there.
No?
Or can you post an example of what you are trying to do with them?
Craig
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 7:31 pm
by richmond62
Both.
Reason lost in time.
Still interested just for fun.
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 8:00 pm
by richmond62
Here's a quick dose of pseudo-code:
Code: Select all
put 1 into CYCLE
repeat until CYCLE > 0x100
-- do something
add 1 to CYCLE
end repeat
That should repeat 256 times (i.e. hex 100).
Re: Repeat loops using Hexadecimal?
Posted: Sat Dec 28, 2024 11:24 pm
by SparkOut
This bit
richmond62 wrote: Mon Oct 07, 2024 4:13 pmCode: Select all
for (i=0x0; i < 0x30; i++) { print("0x0" + i.toString(16) +" = " + i) }
only initialises the two values to control the loop from the hex values 0x0 and 0x30. There's no functional difference in specifying those values as decimal integers 0 and 48. Internally, the loop stores those values presumably as binary floats. Or piles of pebbles. Or whatever. The loop is not counting in hex - the output has to be constructed by creating a string from "0x0" and the value of the loop index
converted to a string representation in base 16 with the appropriate syntax. That's no less "fudgy" than using LC baseConvert syntax.
It should be very straightforward to use baseConvert in the pseudocode loop you mentioned to make this real code, without bending it much.