Discuss Scratch

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 decimal
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
hex numbers: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}

Last edited by NutOfCoco (Oct. 1, 2026 04:09:36)

CK840
Scratcher
5 posts

Official Scratch Workaround Guide VIII

NutOfCoco wrote:

Because of all this decimal to hexidecimal stuff I decided to make my own workaround (for the inverse):
-snip-
We already have a workaround for converting hexadecimal to decimal.

zispe wrote:

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

CK840 wrote:

NutOfCoco wrote:

Because of all this decimal to hexidecimal stuff I decided to make my own workaround (for the inverse):
-snip-
We already have a workaround for converting hexadecimal to decimal.

zispe wrote:

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))

Oh.
NutOfCoco
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

Here is a workaround for the if block:
repeat ()

end
this is a joke, but it works
bitmap_caketin
Scratcher
100+ posts

Official Scratch Workaround Guide VIII

NutOfCoco wrote:

Here is a workaround for the if block:
repeat ()

end
this is a joke, but it works
You do realise that these are workarounds for non-existent blocks?
chickenandcheesesand
Scratcher
100+ posts

Official Scratch Workaround Guide VIII

chickenandcheesesand wrote:

Workaround Type:
Control/My Blocks
Workaround Title:
Immediately create (clones)
Method 1:
define immediately create (clones) clones //run without screen refresh
repeat(clones)
create clone of (myself v)
Description:
i think this might just be too simple or something
just saying this exists (maybe you're busy i dont know)
NutOfCoco
Scratcher
500+ posts

Official Scratch Workaround Guide VIII

bitmap_caketin wrote:

NutOfCoco wrote:

Here is a workaround for the if block:
repeat ()

end
this is a joke, but it works
You do realise that these are workarounds for non-existent blocks?
bitmap_caketin
Scratcher
100+ posts

Official Scratch Workaround Guide VIII

NutOfCoco wrote:

bitmap_caketin wrote:

NutOfCoco wrote:

Here is a workaround for the if block:
repeat ()

end
this is a joke, but it works
You do realise that these are workarounds for non-existent blocks?
I know, but the joke implies that you misunderstood this.

Powered by DjangoBB