Libraryless. Click here for Pure Java version (9244L/51K).
// you should not overflow in the sum... static long longAverage(long... a) { long sum = 0; for i over a: sum += a[i]; ret ldiv_round(sum, l(a)); } static long longAverage(Iterable<Long> l) { long sum = 0; long n = 0; fOr (Long i : l) if (i != null) { sum += i; ++n; } ret ldiv_round(sum, n); }
Began life as a copy of #1010188
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036051 |
| Snippet name: | longAverage |
| Eternal ID of this version: | #1036051/2 |
| Text MD5: | e859b6c2c599d9e7fd9e8db235a404e5 |
| Transpilation MD5: | f598d78d6ed1a842c2273e90f980ab0c |
| Author: | stefan |
| Category: | javax / maths |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-09-03 02:06:49 |
| Source code size: | 331 bytes / 15 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 417 / 542 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |