I've made a block that gives you the expanded form of a number!(Decimals work!)

I've made a block that says the expanded form of a number! Here's what it looks like:
Numbers in expanded form! script pic
It works really well! Here's an example:
Numbers in expanded form! script pic (1)
Here's the code and the link to the project!
Numbers in expanded form! script pic (2)
Numbers in expanded form!

Hmm, could I suggest having the individual numbers in a list instead? That would be more useful for operating on them later.

Good point. I'll change that.

Hey this is really nice..

You can actually do it all with in one block:
Numbers in expanded form! script pic

This is nice. The list output is better if you're going to implement multiplication or something, but the text output is (imho) better if you're building software to teach someone about place value.

If you want another challenge, make it work on decimals, so 12.34 -> 10 + 2 + 0.3 + 0.04

great block, but this is what I get with a decimal
Numbers in expanded form! script pic
which you can tell that it's wrong.

But still pretty cool..

Yeah. I haven't programmed it to deal with decimals yet.

It would be really cool with decimals.

ok

I did it! I managed to get it to work for decimals! And even though it works, to me, just looking at it makes my mind go limp because it's so complicated!
Numbers in expanded form! script pic (3)
Here's the mind-boggling code for it:

Check it out!

@helicoptur It now has the option to be a list OR a string of text! You select which one you want it to be!
Numbers in expanded form! script pic (5)
I'll put the code, but you might have to zoom in in order to even see it.


Note: THIS IS 100% SIZE!!!!!!!!!!

you know you can replace 100% in the text with 200% to make it bigger.

Yeah, but then you can't see the entire script.

oh, ok

I did it! It now works with decimals!

Nice!

Why is it so long? There has to be a way to do it that doesn't use that many blocks. So I sought out the solution, and I found it:


This is basically @legoman3.14's solution (actually we came up with the same solution-- I made what legoman made and was unaware of it). The difference is it finds where the decimal point is, and shifts everything based on it. This actually outputs a list, if you want it to output the + stuff you simply do this:

(There's a floating point precision error at the end, and it's not my fault)
(I didn't test it beforehand but interestingly it still works if you omit the whole number [like in ".3"]. Yours doesn't.)

If you are confused on how it works, I will tell you. This works by determining where the decimal point is (from the right). It splits the text into a list so I can use INDEX OF to find where the decimal point is (like in your solution). If it does find a decimal point, then it stores where it is located, then is made so it is ignored afterwards (by deleting it). If there is no decimal point, it is said it is at position 0, at the beginning. This won't be a problem because then the number would be interpreted as "253.", which is the same thing as "253". Then, it uses MAP to go through every digit in the list to basically do the same thing you are doing, but using the position of the decimal point, it determines the index relative to the decimal point. So the 4 "456.23" wouldn't be at position 5 (from the right, disregarding the decimal point), it would correctly be at position 3 instead. The 2 would be at position -1. And that is how it works.

You should really use those list blocks (like map and combine) more.

P.S. Can you modify that to account for negative numbers? I did it myself very easily, but I would like to see you do it.

You can actually do it in just one block:
untitled script pic (2)
This is the same as my original idea that does not work with decimals, except it bases the power of 10 to multiply by the length of the part before the decimal point, instead of the overall length.