//shoots red green & blue lasers from bottom of fram to top

//or surface-to-air Star Wars anti-Communist anti-satellite

//laser defense sys emulator in 2d

//inspired by TRW Research (active per local eyewitness 10/17/16

//IP Tapper@ssstudios LA,CA

//global vars

int bluelxpos = 38;

int bluelypos = 398;

int laserwidth = 6;

int laserheight = 188;

int redlxpos = 200;

int redlypos = 366;

int gnlxpos = 325;

int gnlypos = 333;

int framecount = 0; //for testing & frame-tracking

void setup(){

size(400,400);

background(0);//k

frameRate(120);//default fr x2

framecount++;

drawlasers();

}

void drawlasers(){

//blue

fill(38, 38, 200);

rect(bluelxpos, bluelypos, laserwidth, laserheight);

//red

fill(255,0,0);

rect(redlxpos, redlypos, laserwidth, laserheight);

//gn

fill(0,255,0);

rect(gnlxpos, gnlypos, laserwidth, laserheight);

laserheight--;

}//end drawlasers

void draw(){

//shoot lasers up

//blue

fill(38, 38, 200);

bluelypos--; //delta y blue laser

rect(bluelxpos, bluelypos, laserwidth, laserheight);

if(bluelypos+laserheight==0){//refire

bluelxpos = (int)random(1,399);

bluelypos = 398;

}//end if

//rd

fill(255,0,0);

redlypos--; //delta y red laser

rect(redlxpos, redlypos, laserwidth, laserheight);

if(redlypos+laserheight==0){//refire

redlxpos = (int)random(1,399);

redlypos = 366;

}//end if

//gn

fill(0,255,0);

gnlypos--; //delta y gn laser

rect(gnlxpos, gnlypos, laserwidth, laserheight);

if(gnlypos+laserheight==0){//refire

gnlxpos = (int)random(1,399);

gnlypos = 333;

}//end if

framecount++;

}//end draw

## The least common multiple of three integers; a solution in Java ….

This was inituially a troubling proposition because I’d mixed up “least common multiple” with greatest common factor. Further, the question posed to solve the LCM of three prime integers, namely; three, five and seven. I answered the question as “duh…one.” and moved on. Thx to fellow wikireviewer Eric Barnes who noted the error. I looked up the euclidean definition of what LCM really means…then coded two functions and tested them in a main class. The code is adequately introduced, commented and documented to explain the algorithm’s process, which is essetailly to calculate the LCM of 5 & 7, then save that 1st lcm and plug it into a separate function that will calulate the final LCM using 3 and “lcm of 5 & 7” as parameters.

/**we define the lcm of three ints as follows:

* LCM(a,b,c)=LCM(LCM(a,b),c)=LCM(a,LCM(b,c))

* the lcm of 3, 5 & 7 is, in fact 105

* last stable build 1/24/16 @ssstudios, los angeles, ca

* IP! &c Tapper7.com, ssstudios and lonely faction productions*/

package gcd;

public class Gcd{

public static int gcd(int a,int b){

int t;

while(b!=0){

t = b;

b = a%b;

a = t;

}

return a;

}//end fxn gcd

public static int lcm(int x, int y){

return(x*y/gcd(x,y));

}//end fxn lcm

public static void main(String[] args){

int lcm1 = 0; //will store the lcm of parameter 2 & 3

int lcm2 = 0; //will store the result of lcm(p1, lcm(p2,p3))

int p1 = 3;

int p2 = 5;

int p3 = 7;

lcm1 = lcm(p2,p3);

lcm2 = lcm(lcm1, p1);

System.out.println("The least common multiple of " +p1+ ", " + p2 + ", "

+p3+ " is " +lcm2);

}//end mn

}//end gcd/lcm class tester

here is the result:

run:

The least common multiple of 3, 5, 7 is 105

BUILD SUCCESSFUL (total time: 0 seconds)

therefore, Barnes is correct. Thank you for pointing out my foible and giving a chance to review & test this classic algorithm. I just set up an entirely new IDE on an entirely new system so this made for great QC on the new devkit & system too.

## A Die Class that implements Crap…I mean ‘Craps’ in Java ….

I took a step back from cards and decks to see if I could design and build a crap game using some object-oriented design. To play the game, we roll two die. The result is determined by the sum of the two rolls….a number between two and 12. Put simply, seven and 11 means the roller “won,” any other result is some form of push or loss…”snake eyes [2]” and “box cars[12]” usually equate to a bust. We can make up specific rules when we implement the game itself, or change them on the fly. The key concept here the abstract data type I built – Class Die.

Lets think about what a die *IS* and what it *DOES*. In computer science terms, we’re going to build a virtual die based on my observation/interpretation of these aspects of this object. For a game of craps, I’m concerned with the die’s current status, that is, what is face up on this hypothetical die right now? What is face up if I create a new one out of thin air? What is face up after I roll it? Compared to a Card, a Die object is relatively simple. While a card has a suit and rank, a die only has a face value. The important thing to consider is that when we roll it, one, two, three, four, five and six should occur with a relatively even distribution – as close to random as we can get. How we determine a random number in this range, how we determine that a computer-generated number is “random” at all is beyond the scope of this discussion; for now …assume that the Java Virtual Machine can in fact do this. We can create another program later to test it, say… a million times and see how evenly the JVM can emulate *randomness*.

Here are the “body parts” of the **Die** I created – “face up” I used an integer and called it “state”…to create a new Die I initialized it to have one be face up. Since I need to read the face, I created a “print state” method. Of course, a “roll” method was created — which will change the state (or not! 1/6th of the time….) I also buiis lt a function that will immediately return the current state (to whatever interface needs to use it) as an integer; this is fast and useful once an actual game using dice is built – common coding standards would ask that we call this a “get[State]”

There are probably a few other things a die has and does, in fact, we should have an ability to put the “state” where we want it; a “set” procedure…in terms of the game; this would presumably be some sort of cheating, so we left it out. For now…anyway here is the abstract data type:

package die;

import java.lang.Math;

import java.util.*;

//this is a WIP!!

public class Die{

int state;

public Die(){

state = 1;

}

public void printstate(){

System.out.println(state + " is face up");

}

public int roll(){

int a;

Random roll = new Random();

a = 1+Math.abs(roll.nextInt()%6);

state = a;

return a;

}

public int getstate(){

return state;

}

}//end Die

The way I built this, a main program will have to create two instances of “Die,” roll them, determine a sum and evaluate/output the result. The class above neatly and concisely provides everything we need to play the game. In the code we will create dice using a statement like this- “Die the1st = new Die();” Let’s take a look at what happens when this line is executed.

the = or assignment operator will move from right to left…so the 1st thing that happens is the cpu allocates memory for it (which shouldn’t cost much more than the memory needed to store one integer 16…perhaps 32 bits (???)…the “new” keyword also pulls the constructor method seen above, which will initialize it to have “one” be “face up” …in the class above — Die(){state=1;}

Then we will create a second die, everything I just said will happen again. In the game, we’re gonna roll ’em and figure out what happens. As we build the main class, we will use printState() and getState() frequently to verify that our dice are behaving like we would expect real dice to. Remember, we are creating them in a strictly abstract sense, we can’t hold them, look at them or actually roll them…so we need to poke and prod at these dice as the game goes … debugging the code if anything out-of-the-ordinary happens.

Later we will take a look at the entire source code; for now lets consider some key moments in a single round of craps. The player rolls, he either wins or loses, so we start by calculating the sum.

mydie.roll();

mydie1.roll();

sum = mydie.getstate()+mydie1.getstate();

The above sum tells us what happened. I added a Boolean method to the Die class to determine victory and a branching-if-then-else method to print what happened …

//this is in the main class

currentstack = currentstack - betamt;

if(won(sum)){

System.out.print(" WINNER ");

currentstack*=3;

}

else if(sum==2 || sum == 12){

System.out.print(" OUCH!! ");

currentstack=0;

bust = true;

}

else{System.out.print(" LOSER ");}

Don’t worry too much about the specifics; it should be easy enough to see that, in pseudocode

SUBTRACT the players bank by how much they BET

IF the player WON

MAKE Notification, increase their money

ELSE the player LOST

IF the player rolled SNAKE EYES or BOXCARS

Make Notification, player BUST

IF the player rolled some other value

Make Notification, reduce their money

The rules I used are arbitrary, essentially we want something good to happen if the roll a seven or 11, something bad to happen if not…and something REALLY BAD to happen if they roll a two or 12. As it is set right now, “snake eyes” or “box cars” leads to player bust- in this case they lose everything and the game is over. Winning triples their money, as written and the game continues provided the player has more than $1 to play with. I’ve yet to decide exactly what happens, but really it doesn’t matter. The design allows for any rules regarding what you get if you win, what you don’t get if you lose, how badly you can lose, if/when the player can choose to quit and if/when the cpu will decide to end the game.

the class method “won” is fairly straightforward. TRUE will be sent back if the condition is met.

public static boolean won(int s){

return(s==7||s==11);

}

In the next installment, I will decide on some actual rules, show some sample outputs of the game in progress along with some research to see if the Java Virtual Machine is, in fact, emulating the rolling of two die by writing a special use-case in which we’ll roll each die a million times and see how normalized the randomness really is.

## Let’s play…I mean…create a prototype ’13’ deck aka Korean Poker!

If you are like me you played this addictive game at lunch, on the bus, during class…whatever you played it constantly because it’s seriously fun and a great way to pass the time. At Capo Valley, we loved this game because it was winnable even if you were dealt a shitty hand, the game encouraged a great deal of shit-talking and merriment. We’d also enhanced it with “insult rules” such as, while dealing, you throw a few of them face-up, just to piss off whoever you want to piss off. It also lended itself to so much cheating that we overlayed a rule; “If no one saw it, it wasn’t cheating.” Technically that is true in the absolute…the difference is that we encouraged cheating because it added more layers of fun, strategy, dexterity, options to win…the perfect game for college-prep band geeks who think to much and are fiercely competitive.

Common ways to cheat when you re the dealer is place a card you want on the bottom of the deck, dealing, 13 cards to each player beginning with west, you get the final card. Desirable cards include the 3 of clubs (whomever holds this card goes 1st…it is much like other games where whomever runs out 1st wins, going 1st on a good hand could end it). The ace of hearts is valued – any run ending in this card is unbeatable (thus you get to go again). Likewise, the 2 of hearts is valued for being the highest card – it is not unbeatable (a two-killer is a double-run-of-three such as 4,4,5,5,6,6) but it’s always nice to have, especially late in the game when most pairs and runs are likely to be all down. Another great way to cheat it to simply hide a card (or two, or more…) wherever you can hide it. The best place seemed to be under the left thigh or up my right sleeve. Another “layered” rule is that if you are caught cheating you forfeit the game (and winning if gambling is involved) – simply trying to look at other people’s cards is another surprisingly easy way cheat.

I won’t waste time with any more specific rules…most of you have never played it…still, the f-ed up ways to mess with the game applies to all of them (and that only scratches the surface) and you can apply the tenets and ideas in this post to YOUR preferred card game.

On topic – I’ve been brushing up on mu Java programming again so as a thought experiment I began to build a “Card” class (ADT, data-type, etc). Once I got that to work I decided to test it by creating an array (a list) of them and ordering them in the exact order they would go in 13. On higher level of this project are the following:

- A Deck Class
- A 13 Class
- A user-interface for the game itself

For now, I simply used my Card data-type to see if I could use a nested-for loop to populate the deck with cards as they from low to high in the game of 13. Software Engineers know that regardless of language, arrays begin at zero. In an object-oriented mode, I decided that “zero” had so little to do with cards/decks/card-games that I would use a place-holder for it. What else is not used…I mean…in actual card games? For most; the Joker(s), so in the interest of something w/in striking distance of elegant design; (in pseuodocode) 0=(string)”joker”

The following is the output from a Deck prototype, which hints at an actual 13 prototype, which is a thought rxp[eriment for the future…particularly the design of three players who can strategize against me…and..on an absurd level of abstraction…try to cheat me if the opportunity comes up and allow me to cheat the non-player-characters.

###### Below is the successful output from the v0 prototype of a 13-Deck

**run:**

whomever gets the 3 of spades goes first.

The following list will create a deck of 52 cards in ’13’ order

1. created the 3 of spades

2. created the 3 of clubs

3. created the 3 of diamonds

4. created the 3 of hearts

5. created the 4 of spades

6. created the 4 of clubs

7. created the 4 of diamonds

8. created the 4 of hearts

9. created the 5 of spades

10. created the 5 of clubs

11. created the 5 of diamonds

12. created the 5 of hearts

13. created the 6 of spades

14. created the 6 of clubs

15. created the 6 of diamonds

16. created the 6 of hearts

17. created the 7 of spades

18. created the 7 of clubs

19. created the 7 of diamonds

20. created the 7 of hearts

21. created the 8 of spades

22. created the 8 of clubs

23. created the 8 of diamonds

24. created the 8 of hearts

25. created the 9 of spades

26. created the 9 of clubs

27. created the 9 of diamonds

28. created the 9 of hearts

29. created the 10 of spades

30. created the 10 of clubs

31. created the 10 of diamonds

32. created the 10 of hearts

33. created the J of spades

34. created the J of clubs

35. created the J of diamonds

36. created the J of hearts

37. created the Q of spades

38. created the Q of clubs

39. created the Q of diamonds

40. created the Q of hearts

41. created the K of spades

42. created the K of clubs

43. created the K of diamonds

44. created the K of hearts

45. created the A of spades

46. created the A of clubs

47. created the A of diamonds

48. created the A of hearts

49. created the 2 of spades

50. created the 2 of clubs

51. created the 2 of diamonds

52. created the 2 of hearts

*QA test* The highest ranking card in 13 is the 2 of hearts

BUILD SUCCESSFUL (total time: 0 seconds)

It works! Created using the Netbeans IDE 8.0.2 on a win8.1 box using the Java SE 8 or Java 1.8 as I call it. SRC follows:

package card;

/** WIP - create a card ADT and enumerate it into a deck

* per "13" rules aka Korean Poker

* @author Tapper7.com last stable build - 12/15 &c ssstudios, los angeles, ca

*/

public class Card{

int suit;

int rank;

Card(){

this.suit = 0;

this.rank = 0;

}//null constr

Card(int suit, int rank){

this.suit = suit;

this.rank = rank;

}//fully-formed constructor to be used when a new card is instantiated

public static void showCard(Card theCard){

//cards are ranked as they are in 13 aka korean poker

//"jokers" hold null memory space so we arent using zeroes

String[] s = {"joker", "spades", "clubs", "diamonds", "hearts"};

String[] r = {"joker", "3", "4", "5", "6", "7", "8",

"9", "10", "J", "Q", "K", "A", "2"};

System.out.println(r[theCard.rank] + " of " + s[theCard.suit]);

}

public static void main(String[] args){

//create an array of cards

Card[] mydeck = new Card[54]; //array is oversized for debug

mydeck[0] = new Card(1,1); //initialize

//test that the lowest card is created correctly

System.out.print(“whomever gets the “);

Card.showCard(mydeck[0]);

System.out.println(“goes first.”);

//populate the 13 deck in order fro m low to high

int currentCard = 1;

int suits = 1;

int ranks = 1;

System.out.println(“The following list will create a deck of 52 cards in ’13’ order”);

for(ranks = 1; ranks < 14; ranks++){//outerloop the ranks from 3 to 2

for(suits = 1; suits < 5; suits++){

mydeck[currentCard] = new Card(suits, ranks);

System.out.print(currentCard+”. “);

System.out.print(” created the “);

Card.showCard(mydeck[currentCard]);

currentCard++; //increment deck position

}//end inner loop

}//end outer loop

//test that the algorithm put the highest card in the correct index:

System.out.print(“*QA test* The highest ranking card in 13 is the “);

Card.showCard(mydeck[52]);

}//end mn

}//end prototype

thanks for stopping by! and now [below], a word form one of our sponsors

## fb compatibility test….

as we cycle through the changes to style and funtion; dear reader; I wanted to share with you an editorial I piced together in the immediate aftermath of the tragedies in Paris. I snapped 15-odd shots from around social media to show how quickly/disturbingly hateful invective against Muslims was growing. At the moment I put this commentary together and shared it on fb; HATE itself was going viral. My intent was alert my “real-life” friends…ask them to keep an opn mind that they not fall prey to the fear-mongering, hate-mongering, monger-mongering…u get the idea. as much as “dislike” (note — didn’t take bait to be hypocrite and say I “hate” fb; even though technically I do and technically that’s ok w/ this writer morally because fb is a corporate-adevertising-agency-subdivision-og-google-and-not-a-person;….there ok to hate fb) Facebook, I like the way they package prose that has a great deal of pics to illustrate it.

What i’m getting at is…as long as we are “under-construction” I will audit my privacy level on fb, so how well MY fb page can communicate to you VIA The SoCal Picayune…and as always, give the “handshake” between my fb & my wp a check-up.

<h2>wp post: fb–we’re going start with the usual checkup, just cough while I put my finger here…

your browser: *coughs* link to post that may or may not be public–coughing from

“fb Chris Welke #9” aka /facebook.com/chris.welke.9/* TEST!

Coughing TO: you@your_ip using your device, os & browser.

prediction – you will not be able to read (10/18) due to privacy setting on fb

WIP – find a way to embed or mimck a fb “story” of this nature in WP & || customize privacy setting to make stories initially written in fb jive with the site, so there is no rework when creative energy strikes, news breaks, or both</h2>

Ok my browser says you are using an older-model desktop PC, so go back to work dummy! This site is #nsfw, labeled “mature” in the meta-data and contains graphic depictions of truth; reality and (God forgive me) the above FB post; once you are able to read it; is political in nature. You’v beean warned 😉 –ed []

below is a test of another “mobile-freindly” multi-media-enabled advert, this once

## From static frames to animation – JavaScript, Java & Processing; coding Art ….

As part of my research, I endeavored to build a **frame** and** tile it** – *evenly*…as you would a column in a upscale restaurant, or as Billy-Buster tiled his lesser-known below-ground pool in the hilltop paradise above San Simeon. Drawing squares, keeping track of their quantity, position and spacing proved unweildy. So back to the drawing board I turned. **The first task was to completely fill a window with squares, evenly spaced, uniformed – no holes.** My first breakthrough was a rectangular grid – from the drawing board I found that instead of looping to keep track of the squares (their origins in CGI coordinates space, their quantity, when to drop down a row, when to stop building them…) oy! I located a KISS-simple solution in the following functions and abstract data types:

- translate(float x, float y); //change the origin from (0,0) to wherever the new block is
- pushMatrix(); //save this data to easily create the next one
- popMatrix(); //carefully & strategically appended to prevent a….
**~~STACKOVERFLOW~~**

*Click to see it transform.*

Some tweaks to a nested-for loop, appropriate “pops” nee popMatrix(); and the careful application of a “random” number generator to produce **cool-colored tiles** —*but not TOO cool* — experiment yielded a random range in Green and Blue to give the tiles a watery sheen, sans magenta, indigo, dark purple and the like. For personal intersest and further research I added a **mouse event** that slows down the animation, eliminates the thin black borders on each tile and zooms in on the whole operation.

At long last “Random dynamic & cool tiles” is up for public consumption:

I could see a pool in Laguna, LA, Vegas or Laughlin with swanky, swarthy, light-up tiles in a pool or on a wall of it’s club …. Bill R. Hearst would be pleased…I like to think so.

Next – I thought about Neil Degrasse Tyson. He says that the “snow” we see on the “TV channels in-between TV channels,” (something our Millennial friends may never fully appreciate…) is ACTUALLY a visual representation of the background radiation that’s permeated the Universe since the Big Bang. UHF & VHF cathode-ray displays pick up this noise and spit out the “ssshhhhhhhh” and the black, white & gray snow we may’ve found on Channel 1 or 3. Mostly, it was annoying and caused us to quickly dial up to CBS, PBS, NBC, FOX or ABC to see what was cookin’….but in the context of nostalgia, the scientific implication of looking back *seven trillion years*; this “snow” is worth an emulation. Using similar logic I fashioned version 1. The snow doesn’t dance around the screen, but the small circular “flakes” and the way they appear to move based on random gray-scale shadings is a nice start. It looks like they move – *kinda*.

**^^^^I slowed the frame rate down to avoid headaches.**

After random “cool” I had to attempt random “warm” –this graphic reminds me of a HollyWood or Vegas marquee. Bright lights seize attention; underscoring the glitz and glamour purported to be found within. The difference is that I think the bulbs this animation emulates are controlled in strict, looping sequences as opposed to my random flashes of “bright” colors controlled by logic.

This animation reminds me of the “Sushi”scene from *“Defending Your Life”* — Albert Brooks’ barmate proudly states that his life accomplishment was coining the phrase “*All Nude. (You know those strip clubs out by LAX? ….*“) You needn’t be a fan of his quirky brand of humor to get huge kick out this classic.

That said, I FINALLY got the computer graphic programs to not only display but animate! The “random- (random number generators are not TRULY random, but they are close)*-ness*” of the algorithms give the displays a kind of innate ability for the computers to create something of *THEIR OWN* — MY LOGIC & Design—>* the computers’ brushstrokes.*

All of the “sketches” (as they call them) on my new OpenProcessing Profile are completely original – designed, built, tested, tweaked and deployed by this writer. If you visit my new page & graphics, the source code is easily visible. Feel free to reproduce it yourself, or make changes/improvements to it. You will find that all of them are optimized –nee “code-golfed.”** I designed these algorithms to use the fewest lines of code, fewest commands and simplest logic to add a layer of mathematical elegance to the aesthetic of each sketch**. Please feel free to download my source code…just plz note that all of them are intellectual property- if you plan to use them in a public/educational or commercial setting…just ask! chris@tapper7.com

More coming soon….plus a litany of fresh podcasts – *“I swear it by the old gods & the new.”* -t []

## Processing animation .js Test ….

*Animation *update* unresponsive – posting src and snapshot of fully developed animation as featured image (above).*

/*Random lerp circle spirals – cwelke @ SSStudios

last stable build 8/29/2015

Rendered in Java 1.8 using the Processing API which access OpenGL w/in Microsoft Windows 8.1*/

//global vars

float r = 0;

float angle = 0;

float rSteps;

float maxR;

float angleSteps;

float cirSZ;

float centerX;

float centerY;

float r1 = 0;

float angle1 = 0;

float rSteps1;

float maxR1;

float angleSteps1;

float cirSZ1;

float centerX1;

float centerY1;

void setup(){

size (840, 720);

smooth();

setRandomValues();

background(#0E0517); //dk purple-k

}

void draw(){

int i = 0;

int maxBlasts = 0;

//warm & cool spherical sprails ~=40

while(maxBlasts < 21){

displayEllipse2();

moveAngle();

moveAngle1();

checkEdges();

maxBlasts++;

}

while(i < 11){

displayEllipse();

moveAngle();

moveAngle1();

checkEdges();

i++;

}

maxBlasts = 0; //layering

while(maxBlasts < 8){

displayEllipse2();

moveAngle();

moveAngle1();

checkEdges();

maxBlasts++;

}

i = 0;

while(i < 4){

displayEllipse();

moveAngle(); moveAngle1(); checkEdges(); i++;

} //noLoop(); }

void setRandomValues(){

rSteps = random(4, 8); maxR = random(20, 160); angleSteps = random(PI/90, PI/9);

cirSZ = random (12, 44); centerX = random(width); centerY = random(height);

rSteps1 = random(6, 12); maxR1 = random(40, 250); angleSteps1 = random(PI/36, PI/18);

cirSZ1 = random (36, 44); centerX1 = random(width); centerY1 = random(height);

}

void moveAngle(){

angle = angle + angleSteps;

r = r + angleSteps*rSteps; }

void moveAngle1(){angle1 = angle1 + angleSteps1;

r1 = r1 + angleSteps1*rSteps1;

}

void displayEllipse(){

float colorValue = map(r, 0, maxR, 0, 1);

color c = lerpColor(#FF0000, #00FF00, colorValue); fill(c); stroke(#ffffff);

float x = centerX + cos(angle)*r;

float y = centerY + sin(angle)*r;

ellipse(x, y, cirSZ, cirSZ);

}

void displayEllipse2(){stroke(#000000); float colorValue1 = map(r1, 0, maxR1, 0, 1);

color d = lerpColor(#6600FF, #8A2EE6, colorValue1); fill(d);

float x1 = centerX1 + cos(angle1)*r1;

float y1 = centerY1 + sin(angle1)*r1;

ellipse(x1, y1, cirSZ1, cirSZ1);

}

void checkEdges(){

if(r >= maxR || r1 >= maxR1)

r = 0;

r1 = 0;

angle = 0;

angle1 = 0;

setRandomValues();

}

//rest

void mousePressed(){

r = 0;

r1 = 0;

angle = 0;

angle1 = 0;

setRandomValues();

}

//apologies if formatting is bad – ill conjure this up as another convenient XML “fast-loader”

//in fact code will appear as such in future posts for convenience and as jpegs for visualization -c

## Something Self-Similar ….

I named my home-studio “**Self-Similarity** Studios” because I’ve always had an affinity for things in science and nature that affect this quality. “AS ABOVE …. SO BELOW” Think about a rock. Hold it in your hand…what color is it? What shape does it have? Note that the rock you are holding and a mountain (or significantly large hill) MAY look alike….just on different scales. Two inches of a shoreline, viewed from above, with a few hundred bits of sand – MAY look like … two MILES of shoreline from 100 stories above, with a few hundred large rocks. Rocks, mountains, trees, shells, coastlines….they all exhibit a self-similarity. This is where nature and artificiality intersect and dove-tail in strange and striking ways. (More images, experiments and abstraction forthcoming)

I briefly had access to tools that could render graphics quickly (and cost-free) – this was the Silicon Graphics Lab at Cal Poly, donated by SGI, the lab ran about 30 workstations, each running SPARC SOLARIS 7 and all wired into a mainframe capable of doing the massive amounts of calculations needed to draw a frame (or a million, as in a feature-length CGI-animated motion picture) required to not only calculate and store (*print*; if need be) but *depict images* that elicit **pure aesthetic beauty.**

Ahhh….where Logic and Art intersect. On the chipset just beneath my fingers and the never-ending-thought-machine hard-wired to my skull and backbone.

To me; numbers are a simple, spiritual truth. People use numbers to lie all the time; but **one** can NEVER be deprived of its *“one-ness”* Carl Sagan said, “The simplest thought like the concept of the number one; is an elaborate logical underpinning. The brain has it’s own language for testing the elegance and consistency of the world.” One is one. QED.

If WWWIII begins at dawn; two will be a prime number. If x is an odd integer, then x + 2 will also be odd. The square root of 2 will be irrational; The sum of The Cantor Set DsubH will be transcendental. Our universe could be obliterated in an instant, but there will still be five and only five regular solids.*

I don’t know about you but I take comfort in that.

Anyway….I had access to this lab for a year; these machines, combined, would still (many years later) dwarf the computing power of yours or my CPU. These machines were used for Raytracing; most famously 1st used in entertainment/(Art!) by John Laseter; the Academy Award winning producer of the short “Luxo Jr.” (and founder of PIXAR).

Luxo is just a lamp, but it took parallel processors days to make him look up, or turn, or jump. Why? – A raytraced image is a 3D scene (Picture the two lamps)….There is ambient and natural light reflected off them, they also project their own artificial light. That’s a lot of photons bouncing around a simple scene – to make it look real; Laseter perfected a technique whereby:

FOR (EVERY PIXEL ON THE SCREEN)

DO (~a million calculations to determine it’s color in RGB Space)

….or a few billion for one frame

….or *difficult-to-express numbers* for a 3-min short film.

I never got to build or try a ray-tracer…they took about an hour to render just one frame. Till recently a complete developer environment was required to render computer graphics —Visual Studio, a UNIX lab, Something big and expensive from Microsoft, SGI, Sun — all in my interest faded when I didn’t have access to the tools; I never really got the chance to explore it–I STILL have unsolved problems from back then. Only now can an affordable computer be had, open-source IDE’s set up, and LOGIC be used to make art: Fast and CHEAP.

The featured picture was created using the Processing java template library. If you have the JDK (see column two) you can build things like this yourself.

Here is the SRC (Source Code) It uses (to me) the complex compsci-concept of **recursion**; whereby by a function (in this case a procedure) calls* itself. It will render a slightly different image every-time it runs and is easily customize-able; I hope you enjoy it as much as I enjoyed designing the algorithm*

/*Algorithm by cwelke @Tapper7.com for Self-Similarity Studios

Last stable build: using Processing API, JDK 1.8, win8.1 5/26/15

Dist under The GNU Public License - compliant with ANSI/ISO std.*/

void setup(){

size(1000, 700);

background(#0F1A0A);

noStroke();

float dec = 0.6;

selfS(width*dec, height*dec, 400);

}//end setup

void selfS(float x, float y, float sz){

float angle, nx, ny;

//last int is transparency--rand switches tint

fill(lerpColor (#002900, #006600, random(1)), 300);

ellipse(x, y, sz, sz);

float rec = 0.6;

if(sz > 1){//recurse to base::do(while px_sz > 1)

angle = random(TWO_PI);

nx = x + sz*rec * sin(angle);

ny = y + sz*rec * cos(angle);

selfS(nx, ny, sz*rec);

angle = random(TWO_PI);

nx = x + sz*rec * sin(angle);

ny = y + sz*rec * cos(angle);

selfS(nx, ny, sz*rec);

angle = random(TWO_PI);

nx = x + sz*rec * sin(angle);

ny = y + sz*rec * cos(angle);

selfS(nx, ny, sz*rec);

}//endIF

}//end selfS

Here is the program run a second time:

As long as we are at it check this out:

Same logic – run a second time:

The source:

/*orig. src by Zack Marlow-McCarthy*/

//modified, formatted, built, debugged and run by Tapper @Tapper7.com

//last stable build at SSStudios 5/27/15

//Processing API builds on JDK 1.8 running win8.1

//rights+compliance: ANSI/ISO std style, Creative Commons & The GNU Public License

float angleRandom1 = .8;

float angleRandom2 = 1/angleRandom1;

float lengthRandom1 = 1.01;

float lengthRandom2 = .08;

void setup(){

size(800,640);

//blue mist mod 5/27

background(#B2B2FF);

smooth();

}

void draw(){

translate(width/2,height);

rotate(PI);

strokeWeight(0);

if(mousePressed == true){

fill(126,20);

rect(-width/2,0,width,height);

strokeWeight(1);

pushMatrix();

translate(random(-width/2,width/2),0);

rotate(random(-PI/9,PI/9));

branch(30,PI/2, 0,0);

popMatrix();

}

}

void branch(float branchLength,float angle,float startX,float startY){

if(branchLength<1){//base case fill(#004A00); noStroke(); ellipse(startX,startY,5,10); stroke(0); }else{ float randomNess = random(0,100); strokeWeight(branchLength/2); float endX = cos(angle)*branchLength; float endY = sin(angle)*branchLength; line(startX,startY,startX+endX,startY+endY); startX += endX; startY += endY; if(randomNess>0 && randomNess<90){ branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2), startX,startY); }else if(randomNess>=90 && randomNess<94){ branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2),startX,startY); branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2),startX,startY); }else if(randomNess>=94 && randomNess<98){

branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2),startX,startY);

branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2),startX,startY);

branch(branchLength/(random(lengthRandom1,lengthRandom1+lengthRandom2)), angle*random(angleRandom1, angleRandom2),startX,startY);

}else{

branch(branchLength,angle,startX,startY);

}//end else

}//end if

}//end recursion

*Proofs to come….[] -t

## More fun with Java 1.8 -ASCII “Art” 101 using Arrays….

This is the type of assignment I would hand out to first year programming students. After introducing the idea of lists, I implore them to solve the following:

Use a list to build an ASCII pyramid using the character of your choice and make it: a) appear “pyramidal” that is, *no leaning,* no right-angles at the base and give it some semblance of aesthetic quality b) your logic should generate EVERY level of the pyramid, that is, no coding “special cases” for the top, middle or bottom rows. The logic must hold sound to construct the entire pyramid as a stand-alone algorithm. c) print your src (source code) and the output of your program to prove to peers that it works.

- This task requires careful dissection of the elements involved:
- variable number of rows
- each row knows how many spaces to print and how many characters
- this involves logical analysis for the left spaces, the chars AND the right spaces
- The algorithm must know when to “endline”/”newline”/
- Careful analysis and monitoring (QA/QC) of the variables during runtime may be needed

For the seasoned programmer this is fairly basic, but involves core mathematical concepts, an element of basic aesthetic design and a good grip on list variable storage; how they are both computed and sent to an output stream (System.out in this case) This is the rough equivalent of “cout <<” for you C/C++ guys

- For extra credit:
- Add a user-interface to ask the user how big to build the pyramid. Include exception-handling for pyramid sizes that are not technically “pyramids” (height = 1 is not a pyramid) heights too large will lose their aesthetic, or their pyramidal structure entirely if built too large or too impractical for the user’s display. (I capped mine at 50 rows) – add warnings depending on the user interface).
- Decorate the pyramid with one or more random characters in addition to your “foundation” block (I used hashtags for my foundation block).
- Invert the pyramid.
- Stack the pyramid atop the inverted one to make a diamond shape…make sure it lines up evenly. No bumps or other strangeness in the middle.

Here is a sample solution; note that I carefully tracked line size, space, building-block-count, row-count & the storage of each…this is crucial to accuracy and QC testing during development time.

This is an acceptable output:

Here is the source code – note brevity in my solution– ~20 lines-*ungolfed!*:

/*

author: Chris "Tapper" Welke

This program generates an ASCII-art 50 row pyramid using hashtags as a building block.

Solution provided for instructional/informational purposes in the areas of lists,

integers, type-casting, dynamic memory allocation, and open-source programming. If you

are new to Java, this is an excellent trial pgm to get you started.

Dist. under the GNU Public License. Free to distribute: please attribute though, ok?:

Last Stable Build: 5/23/15 at Tapper7.com and Self-Similarity Studios courtesy

The Netbeans (Netbeans.org) IDE, Java 1.8 and the std. javac compiler

OS: Win 8.1, Chipset by Intel. Laptop by Hewlett-Packard. Website provided by Media Temple

*/

package learn;

import java.util.Arrays;

public class HashTagASCIIPyramid{

protected static int charlinelength = 100;

public static void main(String[] arg){

float[] asciiStorage = new float[HashTagASCIIPyramid.charlinelength];

int totalHashtags = 1; //initialize builing block total

int charCount = 0; //count building blocks for QC testing

int[] cclist = new int[100]; //record the char generation as it happens

int leftspaces = (int)asciiStorage.length/2;

int rightspaces = (int)asciiStorage.length/2;

int height = 1;

for(int i = 0; i < asciiStorage.length/2; i++){

for (int l = 0; l < leftspaces; l++){

System.out.print(" "); charCount++;

}

for (int t = 0; t < totalHashtags; t++){

System.out.print("#"); charCount++;

}

for (int r = 0; r < rightspaces; r++){

System.out.print(" "); charCount++;

}

System.out.print('\n');

/*QC Tracking: height++; cclist[i] = charCount;*/

leftspaces--; totalHashtags +=2;rightspaces--;

}//end mn loop

}//end mn

}//end class #asciipyramid

Hints: I used space-fillers for the spaces (” “); – left and right brackets plus lots of variable outputs to see what was going on during run-time, my initial design yielded the following output:

run:

**WHOOPS!**

Heh…so clearly there were multiple logic faults, (and I started with tildas, not hashtags….) but it was easy to track the movement of the left and right brackets that debugged the left and right SPACES and not shown are my debugging outputs that checked the length of each row for consistency(it was going over and under 100 – keeping the length of each row equivalent was key to my particular legitimate solution)— *also *that my iterators and arrays were misplaced and thus not controlling and the output correctly.

- Keys to victory:
- increment blocks by TWO; not one
- decrement spaces and increment blocks OUTSIDE the main loop
`rightSpaces--;leftSpaces--totalHashtags+=2;`

## Coming soon: Bill’s adventures at Los Alamos, More Netbeans experiments, tutorials and anything interesting that happens when I have my camera on me.

Lots of great ideas in the works…and let us not forget: Summer is Coming …. Go Santa Clara and Concord! Support your local drum corps by playing bingo, going to shows, donating your time, tailgating at shows and screaming your lungs out when corps brings you to it on the Field of Honor. All signs point to a another stellar season for Red and Blue Banners both; and I wouldn’t have it any other way (scratch that….I’d resurrect Bridgemen, Suncoast, Big 27, Star, Kingsmen, The Freelancers and The Velvet Knights) THEN it’d be roll-out time.

Under the circumstances, putting all politics aside; Thank God for Rosemont, Rockford, Madison, Garfield, Bloooooo, SCV/BD, Cru, Spirit and all other remamining “Big Time DCI” corps still in the hunt, still rockin’ it…gettin ready for the only kickoff I really care about: **Memorial Day Weekend. **A trial by fire where those who make it through will be ready for the best summer of their lives. Hang in there kids, you got this!

Music, Tech, Art, Love and Life; find it all right here at The SoCal Picayune. Your LA/OC home for Drum Corps, Culture, tech-security, experiments and solutions, the occasional off-color joke, scam-hunting, YT highlights and the best (and worst) direct from the minds of this writer, Tapper and Bill Feynman.

Maybe a Memorial Day Anecdote will inspire itself as we begin the approach. hmmmmm…..

[]
Support my sponsors! All are reviewed regularly for legitimacy by the Senior Ethics Auditor: moi

## The Binary Power Series and Java 1.8 ….

Series follow a specific pattern and obey explicit, ineffable rules, like prime numbers….

1, 3, 5, 7, 11, 13, 17, 19, 23…. Or a times-table such as 9…. 18, 27, 36, 45, 54, 63, 72, 81, 90, 99. You get the idea, right? (I hope so or you’ll find this post incredibly boring).

Computers store information in bits. A bit is one memory cell that is known by the CPU to be TRUE or FALSE, one or zero. In the parlance of electrical engineering, this equates to either “very very low voltage” or “hardly any voltage at all.”

**A byte is eight bits: 0000 0000 thru 1111 1111; 1-256**

**Consider 0000, 0001, 0010, 0011, 0100, 0101, 0111, 1111** -OR- (in English) **one, two, three, four five six, seven, eight. To be literal, it’s actually zero through seven,** but let’s not get muddy the waters or scare off any readers due to the “maths.” You don’t need to know much math to understand this information…. So a computer needs half of one byte in order to express “seven” to the world “1111.”

Eight bits comprises two to the eighth power (256) possible binary combos. That’s enough to create a color palette acceptable to the human eye, In RGB-space, three eight-bit numbers (0,0,0) being “K” or Black and (255,255,255) being White – or is it vice-versa? You can always go to www.org for quick reference on non-abstract, “code flavors” such as the above assertion. Ok, so three SETs of 256 bits can broadcast “Game of Thrones” on your laptop screen adequaetely. This is what makes 64-bit machines so exciting…64 is a small number….2^64 (which is the definition of a 64-bit sys) ACTUALLY equals about 18.5 QUINTILLION, or 18.5 x a trillion x a trillion. To give you an idea of size…if you started counting as fast as you could from the time you could speak…or comprehend it and count in your head; if you lived an avg. lifespan (~72.9 yrs) you’d be spitting out “one billion” with your last dying breath. A 64-bit system can express and count to a billion in fractions of a millisecond. So what concerns us about this *TODAY?*

With big data (all the rage) comes big numbers, so I’ve been thinking about them and toying with the limits of large number calculation and output using my laptop’s on-board calculator…it can express a google correctly using a semi-correct scientific notation: “1.e+100” –by that, *Microsoft* means to say “a one followed by 100 zeroes.” I have no way of knowing HOW they arrive at a correct answer to 10^100 considering that the largest unsigned long integer that can be stored in one memory cell by a 64-bit system is stated above..”a 1 followed by 19 numbers” … this means the Calculator App you use combines *multiple *long integers and uses extra memory to store anything *above *2^64 = 18,446,744,073,709,551,616.

Using the Netbeans IDE, I created a program that asks the user to provide a number to act as a power of two. It then calculates and prints the subsequent results to the screen. Integers are preffered because they are fast, accurate and take up very little memory: 16 bits or 2 bytes, which can express numbers on the range of (-32678 to +32678). Integers (or “ints”) can ONLY BE WHOLE NUMBERS, that is, 1.5 is not an int, nor is *e* or *pie* or the *square root of two*.

**Program output for common cases:**

`How many iterations of the Binary Power Series would you like to see calculated and printed?`

0

Ok - you're the boss. No iterations--> no output

How many iterations of the Binary Power Series would you like to see calculated and printed?

1

Binary Power Series 2 to the power of 0 = 1

BUILD SUCCESSFUL (total time: 6 seconds)

How many iterations of the Binary Power Series would you like to see calculated and printed?

2

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

BUILD SUCCESSFUL (total time: 4 seconds)

How many iterations of the Binary Power Series would you like to see calculated and printed?

4

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

BUILD SUCCESSFUL (total time: 6 seconds)

How many iterations of the Binary Power Series would you like to see calculated and printed?

8

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

Binary Power Series 2 to the power of 4 = 16

Binary Power Series 2 to the power of 5 = 32

Binary Power Series 2 to the power of 6 = 64

Binary Power Series 2 to the power of 7 = 128

BUILD SUCCESSFUL (total time: 15 seconds)

```
```

`How many iterations of the Binary Power Series would you like to see calculated and printed?`

16

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

Binary Power Series 2 to the power of 4 = 16

Binary Power Series 2 to the power of 5 = 32

Binary Power Series 2 to the power of 6 = 64

Binary Power Series 2 to the power of 7 = 128

Binary Power Series 2 to the power of 8 = 256

Binary Power Series 2 to the power of 9 = 512

Binary Power Series 2 to the power of 10 = 1024

Binary Power Series 2 to the power of 11 = 2048

Binary Power Series 2 to the power of 12 = 4096

Binary Power Series 2 to the power of 13 = 8192

Binary Power Series 2 to the power of 14 = 16384

Binary Power Series 2 to the power of 15 = 32768

BUILD SUCCESSFUL (total time: 3 seconds)

How many iterations of the Binary Power Series would you like to see calculated and printed?

32

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

Binary Power Series 2 to the power of 4 = 16

Binary Power Series 2 to the power of 5 = 32

Binary Power Series 2 to the power of 6 = 64

Binary Power Series 2 to the power of 7 = 128

Binary Power Series 2 to the power of 8 = 256

Binary Power Series 2 to the power of 9 = 512

Binary Power Series 2 to the power of 10 = 1024

Binary Power Series 2 to the power of 11 = 2048

Binary Power Series 2 to the power of 12 = 4096

Binary Power Series 2 to the power of 13 = 8192

Binary Power Series 2 to the power of 14 = 16384

Binary Power Series 2 to the power of 15 = 32768

Binary Power Series 2 to the power of 16 = 65536

Binary Power Series 2 to the power of 17 = 131072

Binary Power Series 2 to the power of 18 = 262144

Binary Power Series 2 to the power of 19 = 524288

Binary Power Series 2 to the power of 20 = 1048576

Binary Power Series 2 to the power of 21 = 2097152

Binary Power Series 2 to the power of 22 = 4194304

Binary Power Series 2 to the power of 23 = 8388608

Binary Power Series 2 to the power of 24 = 16777216

Binary Power Series 2 to the power of 25 = 33554432

Binary Power Series 2 to the power of 26 = 67108864

Binary Power Series 2 to the power of 27 = 134217728

Binary Power Series 2 to the power of 28 = 268435456

Binary Power Series 2 to the power of 29 = 536870912

Binary Power Series 2 to the power of 30 = 1073741824

Binary Power Series 2 to the power of 31 = 2147483648

BUILD SUCCESSFUL (total time: 4 seconds)

….now let’s see what happens when we get close to 64 iterations:

How many iterations of the Binary Power Series would you like to see calculated and printed?

63

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

Binary Power Series 2 to the power of 4 = 16

Binary Power Series 2 to the power of 5 = 32

Binary Power Series 2 to the power of 6 = 64

Binary Power Series 2 to the power of 7 = 128

Binary Power Series 2 to the power of 8 = 256

Binary Power Series 2 to the power of 9 = 512

Binary Power Series 2 to the power of 10 = 1024

Binary Power Series 2 to the power of 11 = 2048

Binary Power Series 2 to the power of 12 = 4096

Binary Power Series 2 to the power of 13 = 8192

Binary Power Series 2 to the power of 14 = 16384

Binary Power Series 2 to the power of 15 = 32768

Binary Power Series 2 to the power of 16 = 65536

Binary Power Series 2 to the power of 17 = 131072

Binary Power Series 2 to the power of 18 = 262144

Binary Power Series 2 to the power of 19 = 524288

Binary Power Series 2 to the power of 20 = 1048576

Binary Power Series 2 to the power of 21 = 2097152

Binary Power Series 2 to the power of 22 = 4194304

Binary Power Series 2 to the power of 23 = 8388608

Binary Power Series 2 to the power of 24 = 16777216

Binary Power Series 2 to the power of 25 = 33554432

Binary Power Series 2 to the power of 26 = 67108864

Binary Power Series 2 to the power of 27 = 134217728

Binary Power Series 2 to the power of 28 = 268435456

Binary Power Series 2 to the power of 29 = 536870912

Binary Power Series 2 to the power of 30 = 1073741824

Binary Power Series 2 to the power of 31 = 2147483648

Binary Power Series 2 to the power of 32 = 4294967296

Binary Power Series 2 to the power of 33 = 8589934592

Binary Power Series 2 to the power of 34 = 17179869184

Binary Power Series 2 to the power of 35 = 34359738368

Binary Power Series 2 to the power of 36 = 68719476736

Binary Power Series 2 to the power of 37 = 137438953472

Binary Power Series 2 to the power of 38 = 274877906944

Binary Power Series 2 to the power of 39 = 549755813888

Binary Power Series 2 to the power of 40 = 1099511627776

Binary Power Series 2 to the power of 41 = 2199023255552

Binary Power Series 2 to the power of 42 = 4398046511104

Binary Power Series 2 to the power of 43 = 8796093022208

Binary Power Series 2 to the power of 44 = 17592186044416

Binary Power Series 2 to the power of 45 = 35184372088832

Binary Power Series 2 to the power of 46 = 70368744177664

Binary Power Series 2 to the power of 47 = 140737488355328

Binary Power Series 2 to the power of 48 = 281474976710656

Binary Power Series 2 to the power of 49 = 562949953421312

Binary Power Series 2 to the power of 50 = 1125899906842624

Binary Power Series 2 to the power of 51 = 2251799813685248

Binary Power Series 2 to the power of 52 = 4503599627370496

Binary Power Series 2 to the power of 53 = 9007199254740992

Binary Power Series 2 to the power of 54 = 18014398509481984

Binary Power Series 2 to the power of 55 = 36028797018963968

Binary Power Series 2 to the power of 56 = 72057594037927936

Binary Power Series 2 to the power of 57 = 144115188075855872

Binary Power Series 2 to the power of 58 = 288230376151711744

Binary Power Series 2 to the power of 59 = 576460752303423488

Binary Power Series 2 to the power of 60 = 1152921504606846976

Binary Power Series 2 to the power of 61 = 2305843009213693952

Binary Power Series 2 to the power of 62 = 4611686018427387904

**Sixty-four** is the borderline on accuracy using unsigned long integers (as stated above) so I coded it’s calculation and warning appropriately:

How many iterations of the Binary Power Series would you like to see calculated and printed?

64

Binary Power Series 2 to the power of 0 = 1

Binary Power Series 2 to the power of 1 = 2

Binary Power Series 2 to the power of 2 = 4

Binary Power Series 2 to the power of 3 = 8

Binary Power Series 2 to the power of 4 = 16

Binary Power Series 2 to the power of 5 = 32

Binary Power Series 2 to the power of 6 = 64

Binary Power Series 2 to the power of 7 = 128

Binary Power Series 2 to the power of 8 = 256

Binary Power Series 2 to the power of 9 = 512

Binary Power Series 2 to the power of 10 = 1024

Binary Power Series 2 to the power of 11 = 2048

Binary Power Series 2 to the power of 12 = 4096

Binary Power Series 2 to the power of 13 = 8192

Binary Power Series 2 to the power of 14 = 16384

Binary Power Series 2 to the power of 15 = 32768

Binary Power Series 2 to the power of 16 = 65536

Binary Power Series 2 to the power of 17 = 131072

Binary Power Series 2 to the power of 18 = 262144

Binary Power Series 2 to the power of 19 = 524288

Binary Power Series 2 to the power of 20 = 1048576

Binary Power Series 2 to the power of 21 = 2097152

Binary Power Series 2 to the power of 22 = 4194304

Binary Power Series 2 to the power of 23 = 8388608

Binary Power Series 2 to the power of 24 = 16777216

Binary Power Series 2 to the power of 25 = 33554432

Binary Power Series 2 to the power of 26 = 67108864

Binary Power Series 2 to the power of 27 = 134217728

Binary Power Series 2 to the power of 28 = 268435456

Binary Power Series 2 to the power of 29 = 536870912

Binary Power Series 2 to the power of 30 = 1073741824

Binary Power Series 2 to the power of 31 = 2147483648

Binary Power Series 2 to the power of 32 = 4294967296

Binary Power Series 2 to the power of 33 = 8589934592

Binary Power Series 2 to the power of 34 = 17179869184

Binary Power Series 2 to the power of 35 = 34359738368

Binary Power Series 2 to the power of 36 = 68719476736

Binary Power Series 2 to the power of 37 = 137438953472

Binary Power Series 2 to the power of 38 = 274877906944

Binary Power Series 2 to the power of 39 = 549755813888

Binary Power Series 2 to the power of 40 = 1099511627776

Binary Power Series 2 to the power of 41 = 2199023255552

Binary Power Series 2 to the power of 42 = 4398046511104

Binary Power Series 2 to the power of 43 = 8796093022208

Binary Power Series 2 to the power of 44 = 17592186044416

Binary Power Series 2 to the power of 45 = 35184372088832

Binary Power Series 2 to the power of 46 = 70368744177664

Binary Power Series 2 to the power of 47 = 140737488355328

Binary Power Series 2 to the power of 48 = 281474976710656

Binary Power Series 2 to the power of 49 = 562949953421312

Binary Power Series 2 to the power of 50 = 1125899906842624

Binary Power Series 2 to the power of 51 = 2251799813685248

Binary Power Series 2 to the power of 52 = 4503599627370496

Binary Power Series 2 to the power of 53 = 9007199254740992

Binary Power Series 2 to the power of 54 = 18014398509481984

Binary Power Series 2 to the power of 55 = 36028797018963968

Binary Power Series 2 to the power of 56 = 72057594037927936

Binary Power Series 2 to the power of 57 = 144115188075855872

Binary Power Series 2 to the power of 58 = 288230376151711744

Binary Power Series 2 to the power of 59 = 576460752303423488

Binary Power Series 2 to the power of 60 = 1152921504606846976

Binary Power Series 2 to the power of 61 = 2305843009213693952

Binary Power Series 2 to the power of 62 = 4611686018427387904

Binary Power Series 2 to the power of 63 = -9223372036854775808

The longest integer that can be expressed correctly is 4611686018427387904

appx. 4.61 QUINTILLION (4.61E18)

***Requests for over 64 iterations return bad data***

BUILD SUCCESSFUL (total time: 3 seconds)

Note that the 64th iteration (array in location 63 is NEGATIVE…this is obviously not the correct answer. I capped the size of the long int array at 65 memory cells, hence …while it WILL compile (using the std gcc compiler) it will throw an exception and kill the program for values OVER 64:

`Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 65`

Here is the source code I wrote if you’d like to try out my logic, tweak it, or scope-out my old-school design style (it is only lightly code-golfed; the abbreviations the kids use today make for confusing code. I try to use Object-Oriented variable identifiers to make definitive and concise use of comments as well as a style I learned from my days as a Cal Poly CSC Code-monkey:

/* Author: Chris "Tapper" Welke

* dist under the GNU Public License.

* This program tests the upper limit of numbers (long ints)

* of the NetBeans IDE v8.0.2 via the rapid geometric growth

* inherent to The Binary Power Series (BPS). 1, 2, 4, 8, 16 ....

* Two to the 64th power is the highest integer in the series

* it can calculate correctly unaided by extra memory/variables/logic

* Last stable build at Self-Similarity Studios & Tapper7.com,

* Los Angeles, CA 5/15/2015

*/

package series;

import java.util.Scanner;

class BPSeries{

protected static String Name = "Binary Power Series ";

protected static int Base = 2;

public static int gIN(){/**

* This fxn gets and sets the number of BPS iterations from the user

* a warning is displayed for n = 64 and an exception is thrown for n > 64

*/

int userInput;

System.out.println("How many iterations of the " + Name + "would you like to see calculated and printed?");

Scanner in = new Scanner(System.in);

userInput = in.nextInt();

return userInput;

}//end UI gIN

public static void main(String[] arg){

//getNset user-defined number of iterations:

int sIts = BPSeries.gIN();

//declare and allocate space for the cells

int cellKit = 65; //throw exception for >64 pwrs of 2

long[] sCells = new long[cellKit];

int pwr = 0; //initialize superscript

int i = 1; //initialize cell iterator

sCells[0] = 0; //null

sCells[1] = 1; //set cell one to 1 since n^0 = 1 for all n

switch(sIts){

case 0:

System.out.println("Ok - you're the boss. No iterations--> no output");

break;

case 1:

System.out.println(BPSeries.Name + BPSeries.Base + " to the power of " +pwr+ " = "+sCells[i]);

i++; pwr++;

break;

default:

System.out.println(BPSeries.Name + BPSeries.Base +" to the power of 0 = 1");

sCells[3]=(sCells[2]*BPSeries.Base);

i++; pwr++;

while (i<=sIts){
sCells[i]= (sCells[i-1] * BPSeries.Base);
System.out.println(BPSeries.Name + BPSeries.Base + " to the power of "+pwr+" = "+sCells[i]);
i++; pwr++;
}//end while
if(sIts>63){//exception notification/handling for 64 bit chipset

System.out.println("The longest integer that can be expressed correctly is "+ sCells[63]);

System.out.println("appx. 4.61 QUINTILLION (4.61E18)");

System.out.println("***Requests for over 64 iterations return bad data***");

}//endIF

}//end switch

}//end main

}//end BPS

A graphical analysis and more tests will follow this discussion; as well as highlights from

The Doheny Blues Festival, which begins tomorrow, I will review Boz Scaggs and hopefully Los Lobos too. Come get your tap on w/ me this weekend. Boz Scaggs!!! []

Today’s algorithm and number-musings sponsored by: