Event value as unsigned int

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Event value as unsigned int

#1 Post by mackowiakp » 19 Mar 2022, 17:41

Is it possible to take value of event in rule as unsigned integer from given value?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Event value as unsigned int

#2 Post by ThomasB » 19 Mar 2022, 17:55

Have you tried using the [int#n] syntax? I believe it is signed, but avoids float. You can use a rule to handle negative values.

- Thomas

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Event value as unsigned int

#3 Post by mackowiakp » 19 Mar 2022, 18:07

[int#n] stands for integer (signed). Of course It is possible to eliminate minus from number in rule. But is any direct way?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Event value as unsigned int

#4 Post by TD-er » 19 Mar 2022, 23:35

mackowiakp wrote: 19 Mar 2022, 17:41 Is it possible to take value of event in rule as unsigned integer from given value?
See also the abs conversion: https://espeasy.readthedocs.io/en/lates ... ht=abs#abs

Code: Select all

let,1,%eventvalue1%
let,2,abs(%eventvalue1%)
logentry,"This is the integer representation: [int#1]"
logentry,"This is as unsigned int: [int#2]"

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Event value as unsigned int

#5 Post by mackowiakp » 19 Mar 2022, 23:43

Wow! I haven't found the "abs" function anywhere in the documentation. Well, as you can see, it's my mistake.
Thanks TD-er!

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests