subtledoctor Posted July 25, 2016 Share Posted July 25, 2016 How does Weidu have fractions? Say I want to edit the XP value field in .cre files with something like this pseudocode: COPY_EXISTING_REGEXP GLOB ~*.cre~ ~override~ READ_LONG 0x00xx xp SET new_xp = (xp / 5) PATCH_IF xp > 5 BEGIN WRITE_LONG 0x00xx new_xp END BUT_ONLYWhat happens if "new_xp" resolves to 12.5? Link to comment
Jarno Mikkola Posted July 26, 2016 Share Posted July 26, 2016 The READ_LONG is 0x0014. Anyways, the weidu will write the number 12.5 to be 12. Even if it were 12.992... it still is 12. I have this plenty with the Frankenstein that is the iispell mod function that I haven't released yet. Also it should be remembered that the divisional remainder, though not shown in the whole number quotient is always factored in.. so you can easily get surprised by 2+2 = 5... as it could be 2(.3) + 2(.9) = 5(.2) if you don't take this into account. Link to comment
subtledoctor Posted July 26, 2016 Author Share Posted July 26, 2016 Sweet. As long as it doesn't cause crashes. Link to comment
Mike1072 Posted July 26, 2016 Share Posted July 26, 2016 To be clear, it's the integer division operation using / that returns only the whole number quotient. You can use the modulo operator % to determine the remainder of the division, if desired. For example, 7 / 2 is 3 and 7 % 2 is 1. (7 divided by 2 is 3 with a remainder of 1.) You probably did long division with remainders in elementary school. A handy thing to know is that X % 2 will tell you if X is an odd number: odd numbers will leave a remainder of 1, while even numbers will leave a remainder of 0. Euclidean division Link to comment
InKal Posted July 27, 2016 Share Posted July 27, 2016 Modulo Operator exccelent name for my next ESO char best for imperial templar but argonian nightblade healer will do pretty nicely too Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.