[amx-netlinx-common] r36 committed - - Added is_numeric to math.axi...

3 views
Skip to first unread message

amx-netli...@googlecode.com

unread,
Aug 8, 2010, 8:01:30 PM8/8/10
to netlinx-comm...@googlegroups.com
Revision: 36
Author: trueamx
Date: Sun Aug 8 17:00:49 2010
Log: - Added is_numeric to math.axi
- Fixed the language to be more clear (and changed a misspelling that made
me thought it was an internal AMX issue when I first saw it) in string.axi
http://code.google.com/p/amx-netlinx-common/source/detail?r=36

Modified:
/trunk/math.axi
/trunk/string.axi

=======================================
--- /trunk/math.axi Thu May 27 23:58:59 2010
+++ /trunk/math.axi Sun Aug 8 17:00:49 2010
@@ -228,6 +228,26 @@
return (hi & $7FF00000) >> 20 == $7FF &&
!(hi & $FFFFF || math_double_low_to_bits(x))
}
+
+/**
+ * Checks if a string value contains only a numeric value.
+ *
+ * @param a a string to check
+ * @return a boolean, true is a is numeric
+ * @todo support signed numbers
+ */
+define_function char is_numeric(char a[])
+{
+ stack_var integer i
+
+ for (i = 1; i <= length_string(a); i++) {
+ if (!(a[i] >= $30 && a[i] <= $39)) {
+ return 0
+ }
+ }
+
+ return 1
+}

/**
* Compares two numbers and return true if they are within MATH_PRECISION
of
@@ -519,11 +539,12 @@
}


-DEFINE_START
-
-MATH_NaN = math_build_double($7FFFFFFF, $FFFFFFFF)
-MATH_POSITIVE_INFINITY = math_build_double($7FF00000, $00000000)
-MATH_NEGATIVE_INFINITY = math_build_double($FFF00000, $00000000)
-MATH_TWO_52 = 1 << 52
+define_start
+{
+ MATH_NaN = math_build_double($7FFFFFFF, $FFFFFFFF)
+ MATH_POSITIVE_INFINITY = math_build_double($7FF00000, $00000000)
+ MATH_NEGATIVE_INFINITY = math_build_double($FFF00000, $00000000)
+ MATH_TWO_52 = 1 << 52
+}

#end_if
=======================================
--- /trunk/string.axi Thu May 27 23:58:59 2010
+++ /trunk/string.axi Sun Aug 8 17:00:49 2010
@@ -52,7 +52,7 @@
define_function char[STRING_RETURN_SIZE_LIMIT] string_size_error()
{
// handle, alert, ignore etc here
- println("'Return size to small in String.axi'")
+ println("'Maximum return size too small in String.axi'")

return 'error'
}

Reply all
Reply to author
Forward
0 new messages