• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Binary Conversion

Guest
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

Have a game in the making. The game is the logic game "NIM". To be able to code the computers moves, we need to convert the value of the rows from integers to binary so the calculations can be made. How do I accomplish this? Thanks

TOPICS
ActionScript

Views

211

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

function integerToBinaryF(n:int):String{

return n.toString(2);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

So if the variable with the number we wish to convert is "row1". We would have this in the button that begins the conversion :

return row1.toString(2);



And then how would we assign that binary number to a variable to manipulate with?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2015 Apr 17, 2015

Copy link to clipboard

Copied

LATEST

no, use:

var yourbinary:String;

yourbinary=integerToBinaryF(row1);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines