Author: aschnell
Date: Sun Apr 6 13:48:23 2008
New Revision: 46159
URL: http://svn.opensuse.org/viewcvs/yast?rev=46159&view=rev
Log:
- added float builtins trunc and pow
Modified:
trunk/core/VERSION
trunk/core/libycp/src/YCPBuiltinFloat.cc
trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.err
trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.out
trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp
trunk/core/package/yast2-core.changes
Modified: trunk/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/VERSION (original)
+++ trunk/core/VERSION Sun Apr 6 13:48:23 2008
@@ -1 +1 @@
-2.16.43
+2.16.44
Modified: trunk/core/libycp/src/YCPBuiltinFloat.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPBuiltinFloat.cc?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPBuiltinFloat.cc (original)
+++ trunk/core/libycp/src/YCPBuiltinFloat.cc Sun Apr 6 13:48:23 2008
@@ -20,6 +20,7 @@
/-*/
#include
+#include
#include
#include "ycp/YCPBuiltinFloat.h"
@@ -44,7 +45,7 @@
* 1.5 + 2.5 -> 4.0
* </pre>
*/
-
+
if (f1.isNull () || f2.isNull ())
return YCPNull ();
@@ -131,10 +132,52 @@
static YCPValue
+f_trunc(const YCPFloat &f)
+{
+ /**
+ * @builtins trunc
+ * @short round to integer, towards zero
+ * @description
+ * Returns f round to the nearest integer, towards zero.
+ * @param f FLOAT
+ * @return FLOAT
+ * @usage trunc (+1.6) -> +1.0
+ * @usage trunc (-1.6) -> -1.0
+ */
+
+ if (f.isNull ())
+ return YCPNull ();
+
+ return YCPFloat(trunc(f->value()));
+}
+
+
+static YCPValue
+f_pow(const YCPFloat &f1, const YCPFloat &f2)
+{
+ /**
+ * @builtins pow
+ * @short power function
+ * @description
+ * Returns the value of f1 raised to the power of f2.
+ * @param f1 FLOAT
+ * @param f2 FLOAT
+ * @return FLOAT
+ * @usage pow (10.0, 3.0) -> 1000.0
+ */
+
+ if (f1.isNull () || f2.isNull ())
+ return YCPNull ();
+
+ return YCPFloat(pow(f1->value(), f2->value()));
+}
+
+
+static YCPValue
f_tostring (const YCPFloat &f, const YCPInteger &precision)
{
/**
- * @builtin tostring
+ * @builtin tostring
* @short Converts a floating point number to a string
* @description
* Converts a floating point number to a string, using the
@@ -206,6 +249,8 @@
{ "-", "float (float)", (void *)f_neg },
{ "*", "float (float, float)", (void *)f_mult },
{ "/", "float (float, float)", (void *)f_div },
+ { "trunc", "float (float)", (void *)f_trunc },
+ { "pow", "float (float, float)", (void *)f_pow },
{ "tofloat", "float (const any)", (void *)f_tofloat },
{ "tostring","string (float, integer)", (void *)f_tostring },
{ 0 }
Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.err
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.err?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.err (original)
+++ trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.err Sun Apr 6 13:48:23 2008
@@ -99,3 +99,63 @@
----------------------------------------------------------------------
tofloat ("3.14")
----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+"** trunc **"
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (1.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (1.4)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (1.6)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (2.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (-1.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (-1.4)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (-1.6)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+trunc (-2.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+"** pow ** "
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+pow (10., 2.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+pow (10., 1.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+pow (10., 0.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+pow (10., -1.)
+----------------------------------------------------------------------
+Parsed:
+----------------------------------------------------------------------
+pow (10., -2.)
+----------------------------------------------------------------------
Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.out
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.out?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.out (original)
+++ trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.out Sun Apr 6 13:48:23 2008
@@ -23,3 +23,18 @@
(4.)
(42.)
(3.14)
+("** trunc **")
+(1.)
+(1.)
+(1.)
+(2.)
+(-1.)
+(-1.)
+(-1.)
+(-2.)
+("** pow ** ")
+(100.)
+(10.)
+(1.)
+(0.1)
+(0.01)
Modified: trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp (original)
+++ trunk/core/libycp/testsuite/tests/builtin/Builtin-Float.ycp Sun Apr 6 13:48:23 2008
@@ -3,7 +3,7 @@
#
# Filename: Builtin-Integer.ycp
#
-# Purpose: test cases for all integer builtins
+# Purpose: test cases for all float builtins
#
# ---------------------------------------------------------
@@ -51,3 +51,25 @@
(tofloat ("42"))
(tofloat ("3.14"))
+
+("** trunc **")
+
+(trunc (1.0))
+(trunc (1.4))
+(trunc (1.6))
+(trunc (2.0))
+
+(trunc (-1.0))
+(trunc (-1.4))
+(trunc (-1.6))
+(trunc (-2.0))
+
+
+("** pow ** ")
+
+(pow (10.0, 2.0))
+(pow (10.0, 1.0))
+(pow (10.0, 0.0))
+(pow (10.0, -1.0))
+(pow (10.0, -2.0))
+
Modified: trunk/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=46159&r1=46158&r2=46159&view=diff
==============================================================================
--- trunk/core/package/yast2-core.changes (original)
+++ trunk/core/package/yast2-core.changes Sun Apr 6 13:48:23 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Sun Apr 06 13:34:20 CEST 2008 - aschnell@suse.de
+
+- added float builtins trunc and pow
+- 2.16.44
+
+-------------------------------------------------------------------
Sun Apr 6 11:11:55 CEST 2008 - coolo@suse.de
- compile with xcrypt 3
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org