Boolean spacerequirment in javascript

Giganews Newsgroups
Subject: Boolean spacerequirment in javascript
Posted by:  jonas.thornva…@gmail.com
Date: Sun, 6 Apr 2014

I have a datastructure "array" over a user defined range, where i store information about natural numbers.

Right now i basicly store the actual number, and if it is a prime and how it will be presented.

Other properties like if the  number is square, cubic in fibonaci i generate on the fly since it is not as heavy as calculate the primes.

However i am thinking about moving these into the datastructure, but since the script can generate and store 10 000 000 objects/elements indexed i hesitate. Because i do not know how the extra memory requirements storing the bolean properties.

This is my datastructure and initialization right now.
How much space would it take if i added fibonaci,square and cubic booleans into the structure if the scope is one million elements/objects?

Would it save alot of space (and time?) if i stored colors as integers and used a lookup table at printout setting the color?

function arraysize()
{

  for ( i = -scope; i <= scope; i ++ )
  {
      arr[i] =
      {
        count : i,
        fcolor : 'black',
        rheight : 100,
        rwidth : 100,
        rcolor : 'white',
        prime : true
      }
  }
}

Replies