machetemike911 Posted November 13, 2018 Share Posted November 13, 2018 (edited) So for whatever reason papyrus isnt dividing anymore. If I tell it to divide 10/100 then it returns 0.0000 to the floatIf I tell it to divide 100/100 it returns 1 to the floatthere is no in-between. Does anyone know why its doing this?Edit: So I tried 100/90 and it returned as 1.0000. So I guess its just refusing to keep any decimals. I honestly don't know why its doing this...Edit2: So I forced 0.5 into the variable and that worked. so for whatever reason it appears its math.flooring the variable without me telling it to.Script: function Update() float science if Priority > 0 Science = 10/100 endif Debug.notification("Science is: "+Science) endFunction Edited November 13, 2018 by machetemike911 Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 13, 2018 Share Posted November 13, 2018 if your dividing a float use a decimal point!! 10.0 / 100.0 You may get the answer you seek. Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 13, 2018 Share Posted November 13, 2018 Edit: How the does papyrus know that 10 not an INT32? or that 100 not an INT32 if you don't explain it??? so it returns an INT32 Writing random variables then expecting magic is not going to work. Be precise if you expect precision to decimal point. Then you cast it in to a Float, see where this going?? A whole Number As a Float with lots of Zeros. Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 13, 2018 Share Posted November 13, 2018 But if you did 10 * 0.01 .......... it might return a Float.which is the same as 10 /100 which returns an Int Food for thought Link to comment Share on other sites More sharing options...
agerweb Posted November 13, 2018 Share Posted November 13, 2018 But if you did 10 * 0.01 .......... it might return a Float.which is the same as 10 /100 which returns an Int Food for thought If you multiply an integer by a float it will force the FP routines to be used and consequently produce an FP answer, if they were both integers it would use the Int routines. Fairly standard practice in most programming languages. Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 13, 2018 Share Posted November 13, 2018 But if you did 10 * 0.01 .......... it might return a Float.which is the same as 10 /100 which returns an Int Food for thought If you multiply an integer by a float it will force the FP routines to be used and consequently produce an FP answer, if they were both integers it would use the Int routines. Fairly standard practice in most programming languages. Poor choice of words on my part... but I am aware. Let's say might = will for future readers Link to comment Share on other sites More sharing options...
Evangela Posted November 15, 2018 Share Posted November 15, 2018 I encountered this when writing a script for Fallout 4. Self disappointing, since I learned about this before in C++ but forgot. When you expect a result to be a floating point value, then you need to use float point values. Link to comment Share on other sites More sharing options...
NexusComa Posted November 17, 2018 Share Posted November 17, 2018 It's a no brainer. If you make it a float you need to work with it as a float.Best to get this down now as other than Basic most languages do this. C will freak out on you :) Link to comment Share on other sites More sharing options...
mko543 Posted October 15, 2021 Share Posted October 15, 2021 great thanks for you all guys that fix a problem for me Link to comment Share on other sites More sharing options...
Recommended Posts