This module offers functions used by math-related ONO apps.
calc();
Math data to string.
ONO::FW::Apps::Core::Math->calc( $num1, $op, $num2 );
returns: eval($string)
comma_limit();
Limit comma number.
ONO::FW::Apps::Core::Math->comma_limit( $num, $limit );
returns: $num
compare_buttons();
Display comparision buttons.
ONO::FW::Apps::Core::Math->compare_buttons( $i, $CORR, $SOL, $SYM, $stat_wrong, $questions_per_page, $vars_ref );
returns: @BUTS
compare_input();
Compare input field code (also good for debugging).
ONO::FW::Apps::Core::Math->compare_input( $stat_correct, $stat_mistakes, $stat_wrong, $stat_todo );
returns: qq~<input type="$hidden" id="count_cor_id" name="output_web_count_cor" value="$stat_correct"> <input type="$hidden" id="count_mis_id" name="output_web_count_mis" value="$stat_mistakes"> <input type="$hidden" id="count_wro_id" name="output_web_count_wro" value="$stat_wrong"> <input type="$hidden" id="count_tod_id" name="output_web_count_tod" value="$stat_todo"> ~
compare_script();
Compare numbers script.
ONO::FW::Apps::Core::Math->compare_script( );
fix_fp_rounding();
Fix bad floating point rounding problems. Note that force_non_comma_number can be used to process only the part behind the comma.
ONO::FW::Apps::Core::Math->fix_fp_rounding( );
returns: $num
float_to_decimal();
Floating point to decimal conversion. This piece of code has been found here: stackoverflow_DOT_com/ questions/ 22976776/ convert-scientific-notation-to-decimal-not-integer-in-bash-perl
ONO::FW::Apps::Core::Math->float_to_decimal( );
returns: $num
generate_add();
Number generator - addition
ONO::FW::Apps::Core::Math->generate_add( $i, $num1, $num2, $op, $res, $cache1, $cache2, $vars_ref );
returns: ($num1,$num2,$res,$cache1,$cache2,"$DEBUG<br>")
generate_muldiv();
Number generator - multiplication and division
ONO::FW::Apps::Core::Math->generate_muldiv( $i, $num1, $num2, $op, $res, $cache1, $cache2, $vars_ref, $force_flush );
returns: ($num1,$num2,$res,$cache1,$cache2,"$DEBUG,$num1,$num2,$force_flush<br>")
generate_sub();
Number generator - subtraction
ONO::FW::Apps::Core::Math->generate_sub( $i, $num1, $num2, $op, $res, $cache1, $cache2, $vars_ref );
returns: ($num1,$num2,$res,$cache1,$cache2,"$DEBUG<br>")
get_operations();
Get an array of allowed operations.
ONO::FW::Apps::Core::Math->get_operations( );
returns: @opts
make_human_readable();
Make a number human readable.
ONO::FW::Apps::Core::Math->make_human_readable( $num, $num_comma, $num_delimiter );
returns: $num
operation_symbol();
Display an operation symbol (HTML and PDF)
Switches:
-A add is NOT default
-c colorize
-e empty becomes question mark
-p print / pdf mode
-s use slash as division symbol
-x executable (simple code)
ONO::FW::Apps::Core::Math->operation_symbol( );
returns: $symbol
random_number();
Random number generator.
Switches:
-a use _alt for digits, comma, round_up, but only if not empty
ONO::FW::Apps::Core::Math->random_number( $from, $to, $min, $max, $vars_ref, $switches );
returns: $num
range_check();
Check if number matches predefined range.
ONO::FW::Apps::Core::Math->range_check( $max_from, $max_to, $from, $to, $negative, $numsys );
returns: ($from,$to)
range_list();
Check number range - special list mode. Split_mode is simply the total number of elements on a page (6, 9, or 12), x vs y will then be calculated
ONO::FW::Apps::Core::Math->range_list( $i, $vars_ref, $split_mode );
returns: $num
round_up();
Round up a number.
Switches:
-a use _alt for digits, comma, round_up, but only if not empty
ONO::FW::Apps::Core::Math->round_up( $num, $vars_ref, $switches );
returns: $num