Price fraction: Difference between revisions

(→‎{{header|Perl 6}}: Added ternary/conditional-based solution)
Line 644:
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}}==
6,962

edits