Jump to content

[LE] Papyrus not dividing right.


Recommended Posts

So for whatever reason papyrus isnt dividing anymore.

 

If I tell it to divide 10/100 then it returns 0.0000 to the float

If I tell it to divide 100/100 it returns 1 to the float

there 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 by machetemike911
Link to comment
Share on other sites

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

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

 

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

  • 2 years later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...