I believe that you've misinterpreted the Jess documentation. There are three string->number conversion function in Jess (float, integer, and long). They work by calling the type-X-specific "parseX" method:
(float "25") is equivalent to (call Float parseFloat "25") (integer "25") is equivalent to (call Integer parseInt "25") (long "25") is equivalent to (call Long parseLong "25")
The '<numeric-expression>' means something that can be coerced into a form that the parseX methods will handle properly (specifically, they are string representations of floats, integers, and longs, respectively).
So
(float "25") -> 25.0 (float "25.0") -> 25.0 (float "2.5e1") -> 25.0 (integer "25") -> 25 (integer "25.0") -> 25 (integer "2.5e1") -> 25 (long "25") -> 25 ...
which is what you're looking for. Check the Java documentation for these classes and associated methods for more details on what is an admissible numeric expression.
Regards,
Win
Alan Moore wrote:
try:
(bind ?x (call Integer parseInt "25"))
(disclaimer: not tested - your mileage may vary)
alan
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 11, 2003 12:44 PM To: [EMAIL PROTECTED] Subject: JESS: Convert a string to integer
Hi all,
This might seem silly but I **really** cannot figure this one out.
Is there a jess command/function to convert a string to an integer?
ex >(bind ?x "25")
I need to be able to convert the string "25" to an integer to be able to do some comparisons. ex (a ?x&:(= ?x 25))
I looked up the function list and found 2 functions: 1. (integer <numeric-expression>) -> but this needs a numeric expression 2. (long <expression>) Longs in Jess are "second class citizens" in the sense that you ** can't directly do math ** on them.
Thanks in advance.
Kapil Dukle Masters Computer Science University of South Carolina
-------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
-------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
-------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------