-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unility funcs to remove dependency
- Loading branch information
1 parent
9805441
commit 9d1cc69
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
geometric_mean(a::Number, b::Number) = √(a*b) | ||
|
||
function find_under_and_over(a::Number, possible_values::Array) | ||
possible_series_sorted = sort(possible_values) | ||
i, j = 1, 2 | ||
while !(possible_series_sorted[i] ≤ a ≤ possible_series_sorted[j]) | ||
i+=1; j+=1 | ||
end | ||
return possible_series_sorted[i], possible_series_sorted[j] | ||
end | ||
|
||
function norm_to_between_100_and_1000(val::Number; return_OOM=true) | ||
power_of_10 = 0.0 | ||
while val > 1000 | ||
val/=10; power_of_10 += 1 | ||
end | ||
while val < 100 | ||
val*=10; power_of_10 += -1 | ||
end | ||
if return_OOM | ||
return val, power_of_10 | ||
else | ||
return val | ||
end | ||
end |