I have a calculation that returns 12.159437866803227. I would like to round that number to 12.159 or just lose the last 12 digits after the 9. Is this possible? The expression editor calculation is written like this: ( 234 ) * ( ( HP * 1.0 / Weight * 1.0 ) pow 0.3333 )
I even tried: Round ( 234 ) * ( ( HP * 1.0 / Weight * 1.0 ) pow 0.3333 ) and it still returns 12.159437866803227
Any help with this would be great. BTW, this only happens when running this in HTML5. All other run times return shorter numbers.
Rounding numbers or.....
Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.
A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.
Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!
Clickteam.
A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.
Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!
Clickteam.
-
-
Your brackets are a little off.
It should be either
234* (HP*1.0/Weight*1.0)Pow 0.3333
or
Round(234* (HP*1.0/Weight*1.0)Pow 0.3333)To round to a specific number of decimals (3 in this case) try this:
Round((234* (HP*1.0/Weight*1.0)Pow 0.3333)*1000)/1000.0 -
Ok, that worked for that expression, but how would I set this one up to give me 3 digits after the decimal point! The second expression in the picture. Thank you again for helping me out!
-
Round((1353.0/MPH)*1000)/1000
-
Is this just how HTML5 handles float numbers? Is that the reason it's fine on PC and Android because they handle floats differently? Thank you for the expression fix. I'll try the new one you just posted when I get in front of my PC.
-
I'm sorry,..how would this be written to round the number like the others? SetText....
Str$(1353.0 / Val(Edittext$( "E5" )
I am so confused with the expression editor it isn't even funny! I tried this:
Str$(1353.0 / Val(Edittext$( "E6" ) * 1000 / 1000.0
But it says "Mixed strings and numbers" in the expression editor. -
Str$(Round((1353.0/Val(Edittext$("E5"))*1000)/1000)
-
Thank you, but the expression editor is saying "Missing closed bracket?? When I click "where?" it's saying in front of "Round", but I enter one and it doesn't work?
-
Sorry, typo.
there should be 3 close brackets after E5:
Str$(Round((1353.0/Val(Edittext$("E5")))*1000)/1000) -
Perfect!! Thank you again for the fast response. This was a big help and hopefully I'll learn something from this! For some reason, I just can't get my head around the expression editor and writing my own. It seems very difficult.
-
This is a valid expression, but turns up 0 when run in HTML5, but returns correct when run on PC or Android!?
Set Text:
Str$(Round(( Weight * ( MPH / 234 ) pow 3 ) * 1000 ) / 1000 ) -
try changing 234 to 234.0
-
Jezze,..That did it! Thanks again. Is there a book on writing expression or something I can learn from??
-
Pineapple,.need your help again if you don't mind as I can't get these to Round like the others. Again good in PC and Android but not in HTML5.
I tried this and it returns large numbers: Str$(( ( ( Eighth ) * 1000 / 1000 ) + 0.22 ) / 0.655 )
Also this and it returns large numbers: Str$(Round( ( ( Eighth ) * 1000 / 1000 ) + 0.22 ) / 0.655 )
Example,.if I type in 6.6968 in the edit box,.it returns 10.560000003260624. I want it to return 10.560 or 10.56Same thing with these expressions: Str$(( ( Quarter ) * 1000 / 1000 ) * 0.655 - 0.22 )
And this: Str$((Round ( Quarter ) * 1000 / 1000 ) * 0.655 - 0.22 )
Example,..if I type in 10.56,.it returns 6.696799997864291. I want it to return 6.6968 or 6.696They are returning the correct values, but they are to long!!
I tried just about every combo!!
Thank you... -
Str$(Round(((Eighth+0.22)/0.655)*1000)/1000.0)
To explain it:
Your basic equation is (Eighth+0.22)/0.655
Eighth+0.22 is in brackets so that you can be sure that they are added together before being divided by 0.655After that, you multiply your equation by 1000: ((Eighth+0.22)/0.655)*1000 notice that again it has been wrapped in brackets, so that you can be sure the multiplication happens after the main value has been calculated.
Next, you stick that equation inside of Round(). Round will convert your floating point number into the closest whole number (in the case of your equation, 10560)
You then divide the rounded number by 1000.0 to reconvert it to a floating point value: Round(((Eighth+0.22)/0.655)*1000)/1000.0
And then stick the whole equation inside of the Str$() function to convert it into a string: Str$(Round(((Eighth+0.22)/0.655)*1000)/1000.0)
I hope this helps.
-
Hmmm, I tried the expression above and it came back missing closed bracket. So I added a closed bracket to the end and it then was valid, but it's rounding off to far down. I tried to take one zero off the 1000 and it still rounded it to far down. So I ended up shortening the edit boxes so it only shows 5 numbers. Thank you for your time. It was a big help.
It worked adding a last bracket to the end, but rounded off down to one digit values. Example: 6.9868 would return a 7. I need at least 4 or 5 digit returns. This is so difficult in HTML5.
Str$(Round(((Eighth+0.22)/0.655)*1000)/1000.0))For example, in PC runtime or Android it returns if you type in the first edit box 10.56. Then the second edit box returns 6.69680 from typing in 10.56,... But in HTLM5 it returns 6.696799997864291.
-
I double checked, and the equation I posted should be correct, no missing brackets.
Here it is with the Fusion 2.5 formatting:
Str$(Round(( ( Eighth + 0.22 ) / 0.655 ) * 1000 ) / 1000.0 )
-
I will recheck it again. Thank you! Maybe there's something else wrong with how I'm doing the events.
I'm always setting global value "eighth" to val edit box. The when the calculation button is pressed the expression Str$(Round(( ( Eighth + 0.22 ) / 0.655 ) * 1000 ) / 1000.0 ) takes place and the value is place in the other edit box. Seems like that is all working as it should. Like I said, I'll recheck again.
-
Update, your expression worked perfect. I did made a mistake in the second expression though with the math.
The second expression had to read: Str$(Round(( ( Quarter * 0.655 ) - 0.22 ) * 1000 ) / 1000.0 )
Both expression are rounding to a total of 5 numbers now. Excellent!!
Thank you very much for all the help. Also, thank you for explaining how expression are written. I have a lot to learn. -
Just to clarify for those concerned about how the expression editor handles decimals:
A number with no decimals is called an integer. A number with decimals is called a float. When you multiply or divide integers with one another, you will always get an integer result. If any of the involved numbers is a float, you will get a float as a result. This is why 48/32.0 will give a result of 1.5, while 48/32 will give a result of 1. In an integer, the decimal places are simply cut straight off the end. This leads to a handy trick you can use to snap objects to a grid.
X = X / 32 * 32
Y = Y / 32 * 32At first it will divide the position by 32, and since 32 is an integer the decimal places are cut off and it rounds down to the nearest whole number. Then when you multiply, it takes that rounded number which forces the result to be a multiple of 32. I see above there was a discrepancy in HTML5 with rounding which leads me to believe division might always produce floats (don't quote me, never tried it) on that platform, in which case you can manually cast your division to integers in order to force the behaviour.
X = int(X / 32) * 32
Y = int(Y / 32) * 32This is the optimal format as it removes any guesswork as to the underlying mechanics of the expression editor. There would be no change in result by changing 32 to 32.0 in this case.
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!