Number to base block

Definition:


Currently only supports a base of up to 64.
Will be working on a reporter that reverses this, i.e.:

[scratchblocks] [61] from (16 v) :: reporter operators [/scratchblocks]

Credit to @bh for the base idea on:
Decimal to Binary Converter: an electronics-based recursive approach. (post 2)

Isn't that a beautiful algorithm?

Thanks! Yes, it is. (To me, a Scratch/Python/Snap!/learning-Javascript programmer)

Are there any ways you could suggest improving it? (Other than adding support for higher bases, and making a (bnum) from (base) reporter)

Edit: BTW is there a way to have

but not fullwidth, only fullheight? (The font I'm using is Courier New, and I'm making a text engine)

Hi!
I like it too.
I want only to suggest a more compact form
decToBase

Joan

Thanks!

You may have to get the vertical line from a different font... The closest I can find to what you want are
U+23D0 VERTICAL LINE EXTENSION
U+23B8 LEFT VERTICAL BOX LINE
U+23B9 RIGHT VERTICAL BOX LINE
where "closest" means "thin bounding box." But plain old vertical bar (U+007C) can have a thin bounding box if you pick the right font, such as Arial Narrow, Bordeaux Roman Bold LET Plain, Candara (the font used in the Snap! logo), Copperplate Light, Didot, Free Sans, Helvetica Light, Helvetica Neue UltraLight, Helvetica Neue Thin, Herculanum (an especially tall one), Linux Libertine, Minion Pro (also extra tall), Mishafi Gold Regular (super thin and super tall), Nueva Std Condensed, Skia Light Condensed (also super thin and tall), Symbol (tall and thin), Waseem Light (the winner, I think, if you can find it). That's what I found in a quick search.

Only in variable naming. This actually pushes one of my buttons, because almost every CS curriculum except BJC gets it wrong. You're not converting from decimal to base whatever; you're converting from number to base-whatever numeral. You really understand this, because in your inverse block, you use a Text-type input rather than a Number-type input, because that block will convert a numeral into a number.

The reason you think you're converting from decimal is that Snap! happens to use decimal numerals to represent numbers. You can't represent a number directly; the closest you could come would be something like

five = {{:alonzo: :alonzo: :alonzo: :alonzo: :alonzo:}, {:orange_heart: :orange_heart: :orange_heart: :orange_heart: :orange_heart:}, ...}

the set of all sets of length five. So in fact Snap! itself uses something much like your program, with the base input equal to ten, to prepare numbers for display.

(Maybe you think I should be arguing that your program is actually converting base two numerals to some other base. There's a sense in which that's true, since numbers can't be represented directly even inside the computer. But it's more helpful, I think, to reserve the name "binary numeral" for a Text string of zeros and ones, and to think of the computer's internal representation as if it were an actual number.)

P.S. You should learn Scheme next.

Nice, are you reading through old posts?

Yep! (I almost said "Ype!" there)

I can't use another type of font. (I need to use a monospaced font, and I'm so used to Courier New. (Python IDLE default font))

Ok, I'll fix it.    Done.

Why is the Alonzo emoji so wide?

I'll try. (If I can)

Umm, you can't have both a monospace font and a zero-width vertical bar! :~/

I believe all the forum emoji are square.

I guess I could use a sprite, or just use "|", U+FF5C. (Edit: as a workaround)

That's "FULLWIDTH VERTICAL LINE," the opposite of what you want!

But yeah, you could draw a vertical line.

Edit: Wait, you said that yourself, that's how all this started:

a bad choice

Of word(s)? Of what to use for a whamachacallit blinking thing:

a|

press m key:

am|

press left key

a|m

Cursor. If that's what you want, it definitely shouldn't be a character from a monospace font! A sprite sounds fine, better than drawing with the pen, because you'll keep wanting to move it.

But that's another name for a mouse pointer. (I guess I could just use "pointer" for the mouse, though)

Anything that indicates a position can be called a cursor, but the one provided in a text editor doesn't afaik have any other name. Maybe it's not a "pointer" because it's not arrowlike.

Caret, which also refers to ^ above the 6 on most keyboards

What is with "carrot" homophones‽ <-- Interrobang
There're "carrot", "karat", and now "caret"!