2.6 Solutions

    1. abs(-5) - abs(-7)
      = 5 - 7
      = -2
    2. abs(-1e-1) + abs(-2e-2)
      =abs(-0.1) + abs(-0.02)
      =0.1 + 0.02
      =0.12
    3. sqrt(0.0064)
      =0.08
    4. sqrt(pow(2.7, 2))
      =sqrt(2.72)
      =2.7
    5. round(3.499)
      =3
    6.  pow(16, 0.25)
      = fourth root of 16
      = 2.0
    7. pow(4, -2)
      = 1 / 42
      = 1 /16
      = 0.0625
    8. round(1.49 + 0.1)
      = round(1.59)
      = 2
    9. round(1.49) + 0.1
      = 1 + 0.1
      = 1.1
    1. sqrt(a * a - b * b)
    2. PI * (pow(x, 6) - pow(y, 6))
    3. 4.0 / 3 * PI * pow(r, 3)
    4. abs(pow(z, 4) - 1)
    1. result = (int)random(10) + 1;
    2. result = (int)random(52) + 1;
    3. result = (int)random(20) * 5 + 5;
    4. result = (int)random(11) - 5;
    5. result = (int)random(21) * 10 + 100;
    6. result = (int)random(k + 1) * b + a;
  1. randChoice = (char)(random(5) + 'A');
  2. randVal = (int)random(13) * 0.25 + 1;
  3.  
    void setup()
    {
       float x, tenth;
       int thousand;
       x = getFloat("Enter a number to round");
       tenth = round(x * 10) / 10.0;
       thousand = round(x / 1000.0) * 1000;
       println(x + " " + tenth + " " + thousand);
    }