Discuss Scratch
- Discussion Forums
- » Suggestions
- » Official Scratch Workaround Guide VIII
- Mark4SISB
-
Scratcher
69 posts
Official Scratch Workaround Guide VIII
I know that the Hexadecimal Converter block was rejected, but I just thought I'd share a recursive version that allows for all integers.
define convert (number) to hexadecimal //Run w/o Screen Refresh
if <(number) < [0]> then
convert ([abs v] of (number) :: operators) to hexadecimal // Convert the positive number to hexadecimal, then add a minus sign.
set [hex output v] to (join (-) (hex output))
else
set [hex output v] to []
if <not <(number) < (16)>> then // Number will take more than one hexadecimal digit.
convert ([floor v] of ((number) / (16))) to hexadecimal // Convert everything before the last hexadecimal digit.
end
set [hex output v] to (join (hex output) (letter (((number) mod (16)) + (1)) of [0123456789ABCDEF])) // Join the preceding hexadecimal digits to the last one.
end
- NutOfCoco
-
Scratcher
500+ posts
Official Scratch Workaround Guide VIII
Because of all this decimal to hexidecimal stuff I decided to make my own workaround (for the inverse):
define hexidecimal (#) to decimalhex numbers: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
set [output v] to [0]
set [i v] to [0]
if <(letter [1] of (#)) = [-]> then
change [i v] by [1]
end
repeat ((length of (#)) - (i))
change [i v] by [1]
change [output v] by (((item # of (letter (i) of (#))in [hex numbers v]) - [1]) * (round ([e^ v] of (([ln v] of [16]) * ((length of (#)) - (i)))::operators)))
end
Last edited by NutOfCoco (Oct. 1, 2026 04:09:36)
- CK840
-
Scratcher
5 posts
Official Scratch Workaround Guide VIII
Because of all this decimal to hexidecimal stuff I decided to make my own workaround (for the inverse):We already have a workaround for converting hexadecimal to decimal.
-snip-
6.5 hexadecimal to decimal
Scratch can turn hexadecimal numbers (like FF) to decimal numbers (like 255) just by putting the hexadecimal in any math block. Make sure you include the special two characters 0x (zero then X) before the number. You can’t type this in number inputs, but if you get it from blocks like “ask and wait”, a variable, or the “join” block, it will work.ask [what is the number in hexadecimal?] and wait
set [hexadecimal v] to (join [0x] (answer))
set [decimal v] to ((1) * (hexadecimal))
say (join (join (hexadecimal) [ in decimal is ]) (decimal))
- NutOfCoco
-
Scratcher
500+ posts
Official Scratch Workaround Guide VIII
Oh.Because of all this decimal to hexidecimal stuff I decided to make my own workaround (for the inverse):We already have a workaround for converting hexadecimal to decimal.
-snip-6.5 hexadecimal to decimal
Scratch can turn hexadecimal numbers (like FF) to decimal numbers (like 255) just by putting the hexadecimal in any math block. Make sure you include the special two characters 0x (zero then X) before the number. You can’t type this in number inputs, but if you get it from blocks like “ask and wait”, a variable, or the “join” block, it will work.ask [what is the number in hexadecimal?] and wait
set [hexadecimal v] to (join [0x] (answer))
set [decimal v] to ((1) * (hexadecimal))
say (join (join (hexadecimal) [ in decimal is ]) (decimal))
- NutOfCoco
-
Scratcher
500+ posts
Official Scratch Workaround Guide VIII
Here is a workaround for the if block:
repeat ()this is a joke, but it works
end
- bitmap_caketin
-
Scratcher
100+ posts
Official Scratch Workaround Guide VIII
Here is a workaround for the if block:You do realise that these are workarounds for non-existent blocks?repeat ()this is a joke, but it works
end
- chickenandcheesesand
-
Scratcher
100+ posts
Official Scratch Workaround Guide VIII
Workaround Type:just saying this exists (maybe you're busy i dont know)
Control/My Blocks
Workaround Title:
Immediately create (clones)
Method 1:define immediately create (clones) clones //run without screen refreshDescription:
repeat(clones)
create clone of (myself v)
i think this might just be too simple or something
- NutOfCoco
-
Scratcher
500+ posts
Official Scratch Workaround Guide VIII
Here is a workaround for the if block:You do realise that these are workarounds for non-existent blocks?repeat ()this is a joke, but it works
end
- bitmap_caketin
-
Scratcher
100+ posts
Official Scratch Workaround Guide VIII
I know, but the joke implies that you misunderstood this.Here is a workaround for the if block:You do realise that these are workarounds for non-existent blocks?repeat ()this is a joke, but it works
end
- Discussion Forums
- » Suggestions
-
» Official Scratch Workaround Guide VIII