ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Gripes and Goodies
Downloads

Gripes and Goodies Software problems and suggestions

  #1  
Old 02-25-2008
Lolke Koopmans's Avatar
Lolke Koopmans Lolke Koopmans is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Posts: 42
Downloads: 21
Uploads: 0
Thanks: 24
Thanked 14 Times in 10 Posts
Rep Power: 163
Lolke Koopmans is on a distinguished road
Default max() is a deprecated function; use maxof() instead!

By accident I just found out that the 'max' function is working differently then I expected.
I don't know if the description in Flexsim 4.3 is new, but this is what the help file tells me:

Returns the maximum of value1 and value2. Note that in C++, this is defined with a macro, and depending on which value is greater, the value parameter may be evaluated twice. For example, it is improper to use the expression max(bernoulli(30, 5, 2), 3) because this may actually return a 2 since the bernoulli expression is evaluated once to determine which value is greater, and then evaluated a second time to return the value. Therefore, it could return 5 for the first evaluation, and then 2 for the second evaluation. This same functionality has been carried directly into flexscript in order to preserve compatibility with C++. The maxof() command can be used to ensure each value is evaluated only once.

The function 'maxof' is doing what I need, so I will use that function from now on.
I think this is useful to know for everyone!


Thread Thread Starter Forum Replies Last Post
Does there exist a function that can calculate the time weighted average of a value in a Global tabl qin tian Q&A 4 01-20-2008 07:01 PM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.