~eda-qa/leaflang/cpp

« back to all changes in this revision

Viewing changes to share/std_library/std/math.leaf

  • Committer: edA-qa mort-ora-y
  • Date: 2017-08-19 06:03:00 UTC
  • mfrom: (100.1.22 misc)
  • Revision ID: eda-qa@disemia.com-20170819060300-209dwd5884343mi0
merging miscelaneous changes, mainly platform improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//TODO: actually want a much larger integer supported, but any larger causes LLVM error
 
2
alias big_int : integer 128bit
 
3
 
 
4
@import("m.log") multi log : ( : abi_double ) -> ( : abi_double ) raw no_throw
 
5
 
 
6
defn log10 = ( x : float ) -> ( : float ) {
 
7
        return log(x)/log(10)
 
8
}
 
9
 
 
10
@export defn num_decimal_digits = ( x : big_int ) -> ( : integer ) {
 
11
        var l = log10(lossy(x))
 
12
        return lossy(l+1)
 
13
}