Skip to first unread message
Assigned to halatmi...@gmail.com by steve....@gmail.com

Pertti

unread,
May 13, 2015, 9:20:51 AM5/13/15
to mitappinv...@googlegroups.com

Hello,

I'm new to making Android apps and was wondering if you could help me to solve one last issue that I have to finish my app.

I'm about to make an app that has six labels, six groups of checkboxes that have two to four boxes in each group with individual values 1, 2, 4 and 8. The checkbox values are summed to respective group labels when selected. For instance if I check checkboxes from group 1 with values 2,4 and 8, it is then shown in label 1 as 14. This works fine, but now I'm in a need of having those Decimal values converted to Hexadecimals. I would like to maintain the live selection as in when I check a box it returns the value without having to push any button. 

I've found plenty of threads about the opposite conversion like this but haven't been able to reverse these codes to convert Dec to Hex.

Then I've also checked the AI2 block descriptions and found out that this kind of block should exist already but I haven't been able to find it or am I missing something?


Below is one of the groups as an example. I was also thinking that since I've used this code I'll probably have to create another set of labels that will posses the decimal values which would be then assigned to the Dec to Hex converter and show the result in the second set of labels?


Thank you beforehand, hope you can help or give me some advice since I haven't been able to find any help for this issue.

SteveJG

unread,
May 13, 2015, 9:39:10 AM5/13/15
to mitappinv...@googlegroups.com
Thanks for reporting this Pertti.     Yes,

The  Math block documentation indicates 

convert number

Converts number from one base to another. Choices are:
base 10 to hexadecimal, hexadecimal to base 10, base 10 to binary, and binary to base 10,.


but the object is not in the AI2 Math Palette.  


I have mentioned this to the MIT technical staff.   Perhaps we will get an explanation of why the feature is not enabled in AI2.

Regards,
Steve


Hal Abelson

unread,
May 13, 2015, 9:52:41 AM5/13/15
to mitappinv...@googlegroups.com
We're working on this new block,

  But, independent of that, to convert Dec to Hex  see here:

http://stackoverflow.com/questions/5796238/python-convert-decimal-to-hex

Try to do this in blocks as a simple, instructive programming exercise, and a great example of recursion.
The blocks program will look  a lot like the python program.

Abraham Getzler

unread,
May 13, 2015, 11:28:12 AM5/13/15
to mitappinv...@googlegroups.com
See attached for decimal to hex or decimal to binary conversions.
ABG

base_convert.jpg
convert_list.jpg
converted_sample_lists.jpg

Pertti

unread,
May 17, 2015, 8:36:59 AM5/17/15
to mitappinv...@googlegroups.com
Hello,

Thank you very much for your replies! 

For some reason I'm not able to assign the result of the checkbox groups to this conversion or in other words to make the blocks see the need of conversion. The python example is simple enough but I get lost with having to manage with different commands and having this example as "bone without the flesh". I believe that I just have to get more familiar with this block structure to be able to make it work, obviously :)
Reply all
Reply to author
Forward
0 new messages