Repository: Konstantin8105/c4go
Pull request #428 (2019-04-25 08:12:11)

math.c : add llround

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=h1) Report
> Merging [#428](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/868e9aa0f5b8dbbc592180f779dea05eb9d62131?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/428/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #428      +/-   ##
==========================================
+ Coverage   85.13%   85.14%   +0.01%     
==========================================
  Files         191      191              
  Lines       11662    11670       +8     
==========================================
+ Hits         9929     9937       +8     
  Misses       1256     1256              
  Partials      477      477
```


| [Impacted Files](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [program/definition\_function.go](https://codecov.io/gh/Konstantin8105/c4go/pull/428/diff?src=pr&el=tree#diff-cHJvZ3JhbS9kZWZpbml0aW9uX2Z1bmN0aW9uLmdv) | `89.21% <ø> (ø)` | :arrow_up: |
| [noarch/math.go](https://codecov.io/gh/Konstantin8105/c4go/pull/428/diff?src=pr&el=tree#diff-bm9hcmNoL21hdGguZ28=) | `85.71% <100%> (+1.84%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=footer). Last update [868e9aa...e05d493](https://codecov.io/gh/Konstantin8105/c4go/pull/428?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/noarch/math.go b/noarch/math.go
index 8f447b7..fea0a05 100644
--- a/noarch/math.go
+++ b/noarch/math.go
@@ -147,3 +147,19 @@ func Erff(x float32) float32 {
 func Erfcf(x float32) float32 {
 	return float32(math.Erfc(float64(x)))
 }
+
+func LRound(x float32) int32 {
+	return LRoundl(float64(x))
+}
+
+func LRoundl(x float64) int32 {
+	return int32(math.Round(x))
+}
+
+func LLRound(x float32) int64 {
+	return LLRoundl(float64(x))
+}
+
+func LLRoundl(x float64) int64 {
+	return int64(math.Round(x))
+}
diff --git a/program/definition_function.go b/program/definition_function.go
index 193467b..21a4730 100644
--- a/program/definition_function.go
+++ b/program/definition_function.go
@@ -205,6 +205,14 @@ var builtInFunctionDefinitions = map[string][]string{
 		"double hypot(double, double) -> math.Hypot",
 		"float hypotf(float) -> noarch.Hypotf",
 		"long double hypotl(long double, long double) -> math.Hypot",
+
+		"long int lround(double ) -> noarch.LRound",
+		"long int lroundf(float ) -> noarch.LRound",
+		"long int lroundl(long double ) -> noarch.LRoundl",
+
+		"long long int llround(double ) -> noarch.LLRound",
+		"long long int llroundf(float ) -> noarch.LLRound",
+		"long long int llroundl(long double ) -> noarch.LLRoundl",
 	},
 	"stdio.h": {
 
diff --git a/scripts/scripts.txt b/scripts/scripts.txt
index fe33ee4..119ac24 100644
--- a/scripts/scripts.txt
+++ b/scripts/scripts.txt
@@ -56,7 +56,7 @@ Calculate warnings in file: ./testdata/neatroff/neatroff.go
 
 Calculate warnings in file: ./testdata/redis/redis.go
 		After transpiling : 0 warnings.
-		Go build : 4 warnings
+		Go build : 50 warnings
 		Unsafe   : 262
 
 Calculate warnings in file: ./testdata/neatvi/neatvi.go


Test patch:
diff --git a/tests/math.c b/tests/math.c
index aede270..cdf2061 100644
--- a/tests/math.c
+++ b/tests/math.c
@@ -12,7 +12,7 @@ unsigned long long ullmax = 18446744073709551615ull;
 
 int main()
 {
-    plan(488);
+    plan(496);
 
 	{
 		diag("modf");
@@ -787,5 +787,18 @@ int main()
         is_eq(n, 4);
     }
 
+	diag("round");
+	{
+	   is_eq(lround(2.3), 2);
+	   is_eq(lround(3.8), 4);
+	   is_eq(lround(-2.3), -2);
+	   is_eq(lround(-3.8), -4);
+
+	   is_eq(llround(2.3), 2);
+	   is_eq(llround(3.8), 4);
+	   is_eq(llround(-2.3), -2);
+	   is_eq(llround(-3.8), -4);
+	}
+
     done_testing();
 }