Pular para o conteúdo

The Math Class

Introduzido
Material de apoio Assistir aula
English

Trace a random range at both ends

  • Tickets need integer labels from 4 through 9 inclusive. Use (int)(Math.random() * 6) + 4.
  • Scaling gives values from 0 up to but not including 6; truncating gives 0 through 5; shifting gives 4 through 9.
Trace a random range at both ends: (int)(Math.random() * 6) + 4 scales to values from 0 up to but not including 6, truncates to 0 through 5, and shifts to 4 through 9; casting first, (int)Math.random() * 6 + 4, always gives 4

Material de apoio

Entrar ou criar conta

IGCSE, A-Level & AP