FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   Add to FavoritesAdd to Favorites  * Code Snippets
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    RSS Get RSS Feed  


What's the difference between Trunc and Int?

 
Post new topic   Reply to topic    Macro Scheduler and Windows Automation Forum Index -> Beginners
View previous topic :: View next topic  
Author Message
Humanetico
Newbie


Joined: 16 Aug 2011
Posts: 4

Reputation: 10

PostPosted: Tue Sep 20, 2011 10:46 pm    Post subject: What's the difference between Trunc and Int? Reply with quote

For a widely range of values tested by me in Macroscheduler (positive and negative values), Trunc and Int functions returns a same integer value. If possible, I wish a example where Trunc and Int evaluates in a different integer value.

In addition, never occured in my tests a round operation in both functions, only a truncate operation. Is this behavior expected? What's the meaning of the words " ... rounded toward zero." in Macroscheduler's help for this two functions?

Thank you.

Did this message help you? If so please reward the poster with Reputation Points? Reward Points
Back to top
View user's profile Send private message
JRL
Automation Wizard


Joined: 10 Jan 2005
Posts: 2650
Location: Iowa
Reputation: 993.5
votes: 91

PostPosted: Wed Sep 21, 2011 2:59 am    Post subject: Reply with quote

Does this info help? I suspect there might be a difference between a floating point value and an integer value in Delphi but not in Macro Scheduler. Macro Scheduler is written in Delphi.
_________________
A few homemade utilities

Did this message help you? If so please reward the poster with Reputation Points? Reward Points
Back to top
View user's profile Send private message
Humanetico
Newbie


Joined: 16 Aug 2011
Posts: 4

Reputation: 10

PostPosted: Wed Sep 21, 2011 1:26 pm    Post subject: Reply with quote

Thank you, JRL. Your Delphi Basics link was very useful. In this link I found too a good explanation about Round function:

===
The Round function rounds a floating point Number to an Integer value.

The rounding uses Bankers rules, where an exact half value causes a rounding to an even number:

12.4 rounds to 12
12.5 rounds to 12 // Round down to even
12.6 rounds to 13

13.4 rounds to 13
13.5 rounds to 14 // Round up to even
13.6 rounds to 14

===

I made a test and Macroscheduler use Bankers rules too in your Round function, although in Macroscheduler help is said: " ... If X is exactly halfway between two whole numbers, the result is the number with the greatest absolute magnitude.".

Thanks.

Did this message help you? If so please reward the poster with Reputation Points? Reward Points
Back to top
View user's profile Send private message
Display posts from previous:    View previous topic :: View next topic  
Post new topic   Reply to topic    Macro Scheduler and Windows Automation Forum Index -> Beginners All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group