mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
parent
c0d15d6d0e
commit
6cb391f9a2
4 changed files with 46 additions and 6 deletions
2
NEWS
2
NEWS
|
@ -234,6 +234,8 @@ New Functionality
|
|||
can happen in packet loss or packet re-ordering scenarios. Such connections will
|
||||
have a ``^`` added to their history.
|
||||
|
||||
- New bifs for ``ceil()`` and ``log2()`` have been added.
|
||||
|
||||
Changed Functionality
|
||||
---------------------
|
||||
|
||||
|
|
38
src/zeek.bif
38
src/zeek.bif
|
@ -1680,19 +1680,33 @@ function print_raw%(...%): bool
|
|||
##
|
||||
## Returns: The next lowest integer of *d* as :zeek:type:`double`.
|
||||
##
|
||||
## .. zeek:see:: sqrt exp ln log10 pow
|
||||
## .. zeek:see:: ceil sqrt exp ln log2 log10 pow
|
||||
function floor%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(floor(d));
|
||||
%}
|
||||
|
||||
## Computes the smallest integer greater or equal than the given :zeek:type:`double` value.
|
||||
## For example, ``ceil(3.14)`` returns ``4.0``, and ``ceil(-3.14)``
|
||||
## returns ``-3.0``.
|
||||
##
|
||||
## d: The :zeek:type:`double` to manipulate.
|
||||
##
|
||||
## Returns: The next lowest integer of *d* as :zeek:type:`double`.
|
||||
##
|
||||
## .. zeek:see:: floor sqrt exp ln log2 log10 pow
|
||||
function ceil%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(ceil(d));
|
||||
%}
|
||||
|
||||
## Computes the square root of a :zeek:type:`double`.
|
||||
##
|
||||
## x: The number to compute the square root of.
|
||||
##
|
||||
## Returns: The square root of *x*.
|
||||
##
|
||||
## .. zeek:see:: floor exp ln log10 pow
|
||||
## .. zeek:see:: floor ceil exp ln log2 log10 pow
|
||||
function sqrt%(x: double%): double
|
||||
%{
|
||||
if ( x < 0 )
|
||||
|
@ -1710,7 +1724,7 @@ function sqrt%(x: double%): double
|
|||
##
|
||||
## Returns: *e* to the power of *d*.
|
||||
##
|
||||
## .. zeek:see:: floor sqrt ln log10 pow
|
||||
## .. zeek:see:: floor ceil sqrt ln log2 log10 pow
|
||||
function exp%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(exp(d));
|
||||
|
@ -1722,19 +1736,31 @@ function exp%(d: double%): double
|
|||
##
|
||||
## Returns: The natural logarithm of *d*.
|
||||
##
|
||||
## .. zeek:see:: exp floor sqrt log10 pow
|
||||
## .. zeek:see:: floor ceil sqrt exp log2 log10 pow
|
||||
function ln%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(log(d));
|
||||
%}
|
||||
|
||||
## Computes the base 2 logarithm of a number.
|
||||
##
|
||||
## d: The argument to the logarithm.
|
||||
##
|
||||
## Returns: The base 2 logarithm of *d*.
|
||||
##
|
||||
## .. zeek:see:: floor ceil sqrt exp ln log10 pow
|
||||
function log2%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(log2(d));
|
||||
%}
|
||||
|
||||
## Computes the common logarithm of a number.
|
||||
##
|
||||
## d: The argument to the logarithm.
|
||||
##
|
||||
## Returns: The common logarithm of *d*.
|
||||
##
|
||||
## .. zeek:see:: exp floor sqrt ln pow
|
||||
## .. zeek:see:: floor ceil sqrt exp ln log2 pow
|
||||
function log10%(d: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(log10(d));
|
||||
|
@ -1748,7 +1774,7 @@ function log10%(d: double%): double
|
|||
##
|
||||
## Returns: The number *x* raised to the power *y*.
|
||||
##
|
||||
## .. zeek:see:: exp floor sqrt ln log10
|
||||
## .. zeek:see:: floor ceil sqrt exp ln log2 log10
|
||||
function pow%(x: double, y: double%): double
|
||||
%{
|
||||
return zeek::make_intrusive<zeek::DoubleVal>(pow(x, y));
|
||||
|
|
|
@ -3,8 +3,13 @@
|
|||
2.0
|
||||
-4.0
|
||||
-3.0
|
||||
4.0
|
||||
3.0
|
||||
-3.0
|
||||
-2.0
|
||||
1.772005
|
||||
23.103867
|
||||
1.144223
|
||||
0.49693
|
||||
1.650765
|
||||
22.21669
|
||||
|
|
|
@ -14,6 +14,11 @@ event zeek_init()
|
|||
print floor(c);
|
||||
print floor(d);
|
||||
|
||||
print ceil(a);
|
||||
print ceil(b);
|
||||
print ceil(c);
|
||||
print ceil(d);
|
||||
|
||||
print sqrt(a);
|
||||
|
||||
print exp(a);
|
||||
|
@ -22,5 +27,7 @@ event zeek_init()
|
|||
|
||||
print log10(a);
|
||||
|
||||
print log2(a);
|
||||
|
||||
print pow(a, b);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue