Price fraction: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: Added ternary/conditional-based solution) |
|||
Line 644: | Line 644: | ||
0.5 0.18 0.18 0.1 0.62 0.7 1 1 0.1</lang> |
0.5 0.18 0.18 0.1 0.62 0.7 1 1 0.1</lang> |
||
This implementation performs a binary search on the boundary values, and then uses the resulting index to select from the result values. |
|||
To prevent J's binary search from doing the wrong thing for values equal to a boundary, both the boundary values and the search value are negated. |
|||
=={{header|Java}}== |
=={{header|Java}}== |