See the Euclidean Algorithm at
Thank you very much. Just one thing. Now how to convert this fraction to a decimal number, like 2-10, 0.2, please do not delete.
There is a block for that.
I forget the name. (Format as decimal?)
Look in the math blocks section.
To convert a fraction into a decimal like 2/10, simply do the division 2 ÷ 10.
Honestly, I mean the opposite, that is, the user enters 0.5, for example. The answer is that it should be a simple fraction, which is here 1_2 Please help me
This is what you asked, but since you want the opposite, I'll try my best.
However, have you tried these?
A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 - the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles.
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling.
Also do the tutorials at http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor 2.
You posted 14 topics about how to do things with MIT App Inventor. I understand that you need help, but have you tried to learn MIT App Inventor yourself?
App Inventor is like fishing. You can't tell us to fish for you just because you don't have time always- you must learn to fish in order to get your fish.
I'm sorry I did not understand what you mean because I use a translator. Do you mean that you have seen the relevant books? No, because I do not have enough time, please help me
Yes. Have you searched on Google, YouTube or in the MIT App Inventor Library for answers?
I mean guidance on whether it is possible to convert decimals to fractions
Ok, I'll try.
com.gordonlu.decimal2fraction.aix (6.0 KB)
Try this extension.
If somebody post a method with this with built-in blocks, I'll be glad.
It worked great just one more thing how to put the denominator in a separate text and the face in a separate text
Can you give me a demo? I don't understand.
For example, instead of writing 12/2 in the answer, I want to put 12 in a text and 2 in a separate text.
Thank you.....
You don't have to use a translator - feel comfortable to post in your own language. Some translators are not accurate, which complicate things. We use the Yandex Translate in our community, which might be more accurate.
Also, saying that you don't have time is not an excuse for not learning App Inventor. Without learning the basics of App Inventor, how are you going to build a successful app?
A journey of a thousand miles begins with a single step. - Lao-tzu, Chinese philosopher
From @Taifun
Learning things all take time. Instead of thinking the product, think about how to make the product.
To turn a decimal number into a numerator and denominator,
- split the number at '.'
- if the resulting list has only 1 item,
- then the numerator is item 1 and the denominator is 1.
- else
- set local power = 10 ^ (text length of item 2)
- numerator = original number * power
- denominator = power
- if the resulting list has only 1 item,
Example with 3.14 as original number
Split at '.' to get list [3,14]
Length ('14') = 2
power = 10 ^ 2 = 100
numerator = 3.14 * 100 = 314
denominator = 100
Yes you're right, but this is what I get.
Usually you might want to get a whole number as a decimal result, but that's ok.
Also, the fraction can be simplified. In the screenshot below, the top result is with built-in blocks, the next one is the extension.
That's an interesting counterexample (math block 0.124354)
I think it failed in my code because of the inexact nature of AI2 floating point numbers.
Thanks, that was fun.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.