Mercurial > hg > fxanalyse
annotate future.c @ 22:b7b3b5f1c5a6
Remove unused widgets from N1 measurement panel. Harmonize widgets names
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 19 Jul 2012 20:01:40 +0200 |
parents | 9d57d1fcbcd5 |
children | be814b934eca |
rev | line source |
---|---|
16
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
1 /* welcome in the 2012 */ |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
2 |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
3 /* required by CVI */ |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
4 #include <ansi_c.h> |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
5 |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
6 /* an implementation of the C99 `round` function based on `floor` and `ceil` */ |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
7 double round(double x) |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
8 { |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
9 if (x >= 0.0) { |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
10 double y = floor(x); |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
11 if (x - y >= 0.5) |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
12 y += 1.0; |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
13 return y; |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
14 } else { |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
15 double y = ceil(x); |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
16 if (x - y >= 0.5) |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
17 y -= 1.0; |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
18 return y; |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
19 } |
9d57d1fcbcd5
Implementation of the C99 round() function
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
20 } |