Last active
August 29, 2015 14:11
-
-
Save mustmodify/a68d131871be9af212ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gap_weight_for( age ) | |
difference = (value_of(age) - patient_age).abs | |
( difference * 0.1 ) ** 1.07 | |
end | |
intermittently results in: | |
in `**': #<Class:0x0000000a693110> can't be coerced into BigDecimal (TypeError) | |
def gap_weight_for( age ) | |
difference = (value_of(age) - patient_age).abs | |
begin | |
( difference * 0.1 ) ** 1.07 | |
rescue => ex | |
puts "#{difference.inspect} or #{(difference * 0.1).inspect} was a math problem." | |
end | |
end | |
results in: | |
#<BigDecimal:12a1b168,'0.45E2',9(27)> or #<BigDecimal:12a33e70,'0.45E1',18(36)> was a math problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tries = 10000 | |
@failures = [] | |
@tries.times do |i| | |
begin | |
BigDecimal.new('2E0') ** 1.07 | |
putc '.' | |
rescue | |
putc 'x' | |
@failures << i | |
end | |
end | |
puts "Failed #{@failures.size} times out of #{@tries.to_s} tries." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x.....................................................................................................................................................................................................................................................................................................................................................................................................................x...................................................................................................................................................................................................................................................................... | |
Failed 20 times out of 10000 times. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment