(function() { var array = []; var types = shuffle( [1, 1, 1, 2, 2, 2, 3, 3, 3], 5 ); var used = {}; while ( array.length < 5 ) { var type = types[ array.length ]; switch ( type ) { case 1: // decimal var n = randRange( 100, 999 ) / 1000; var ns = n.toFixed( 3 ); if ( !used[ ns ] ) { array.push([ type, n, ns, "= " + ns ]); used[ ns ] = true; } break; case 2: // percentage var n = randRange( 100, 999 ) / 1000; var ns = n.toFixed( 3 ); if ( !used[ ns ] ) { array.push([ type, n, (100 * n).toFixed( 1 ) + "\\%", "= " + ns ]); used[ ns ] = true; } break; case 3: // fraction var d = 4 * randRange( 5, 15 ); var n = randRange( 1, d - 1 ); var ns = ( n / d ).toFixed( 3 ); if ( !used[ ns ] ) { var gcd = KhanUtil.getGCD( n, d ); array.push([ type, n/d, fractionReduce( n, d, true ), "\\approx " + ns, (n/gcd) + "/" + (d/gcd) ]); used[ ns ] = true; } break; } } return array; })() jQuery.map( NUMS, function( el ) { return el[2]; } ).join( "," ) jQuery.extend( true, [], NUMS ).sort( function(a, b) { return a[1] - b[1]; } ) jQuery.map( NUMS_SORT, function( el ) { return el[3].match( / (.+)$/ )[1]; } ).join( "," ) jQuery.map( NUMS_SORT, function( el ) { return el[4] || el[2]; } ).join( "," ) (function() { var texts = [ NUMS_SORT_TEXT ]; while ( texts.length < 5 ) { var pi; while ( 1 ) { pi = KhanUtil.shuffle( NUMS ); var maxd = 0, maxp = 0; var fail = false; for ( var i = 0, l = pi.length; i < l; i++ ) { var type = pi[i][0]; if ( type === 1 ) { fail = fail || pi[i][1] < maxd; maxd = pi[i][1]; } else if ( type == 2 ) { fail = fail || pi[i][1] < maxp; maxp = pi[i][1]; } } if ( !fail ) { break; } } var text = jQuery.map( pi, function( el ) { return el[4] || el[2]; } ).join( "," ); if ( jQuery.inArray( text, texts ) === -1 ) { texts.push( text ); } } return texts; })()

Uporządkuj liczby od najmniejszej do największej:

NUMS_TEX

NUMS_SORT_TEXT

  • CHOICE_TEXTS[1]
  • CHOICE_TEXTS[2]
  • CHOICE_TEXTS[3]
  • CHOICE_TEXTS[4]

Zamień wszystkie liczby na ułamki dziesiętne.

\begin{align*} NUM[4] || NUM[2] & NUM[3] \\ \end{align*}

Uporządkuj tak zapisane liczby: NUMS_SORT_DECS.

Zmień spowrotem na ułamki zwykłe: NUMS_SORT_TEXT.