Having a little bit of a math problem, i need a way in blue prints to take a number say 19 split that number in to 2 numbers of 10 and 9, but the number 19 could be anything 28, 20, 87 any thing so how can i make sure when i split the numbers up is does it by as close to half as possible without getting decimal points or remainders?
i know is a bit of an odd question so if anyone needs anymore details please ask
Hello,
i recently used something which may help you : “fraction” :
calc number /2 then branch : fraction = 0 True : number/2 x 2. False : (number+1) / 2 and (number - (number+1) / 2)
(i haven’t find a way to check if a number is peer or not…)
Just use the remainder to give you the other number. Basically, assuming you have 19, you would divide 19 by 2.0, giving you 9 and a remainder of 1. Then you just add the result and the remainder and you get 10 (you can call ToInt to get the value as a whole number). You can wrap that into a function easily.
yeah thanks mate really helped me but just hit a snag if i divide a number under 1 e.g 0.7 divided by 2 i get a 0 remainder and return value, i understand why that is for whole numbers but now im looking for something for less then whole e.g. 0.7 divided 2 = remainder 0.1 and return value of 0.3 is there a way of still using node with some equations before and after to still get affect thanks for all the help
What exactly do you want in case? Do you only want it for a certain level of fraction? For example, tenths (0.0-0.9), hundreths (0.01-0.09), etc? If so, you can just multiply the input value by, say 10 for tenths (100 for hundreths), then do it as usual, then divide the resulting values by the same number.
The Problem seams to be that i can not divide the return value of the Divide (Whole and Remainder) node at all even if i set a variable from it and im not sure why?
The return value is an Integer. You need to convert it to a float and divide by 10.0. If you divide 7 as an integer by 10, you’ll get 0; if you divide 7.0 by 10.0, you’ll get 0.7.
In context, the remainder only exists for integer division. When you divide fractions, you don’t get a remainder and 0.7 represents the fraction 7/10ths. You need to scale things up to whole numbers to be able to use splitting method. If you only ever are dealing with one decimal place, you can just multiply your numbers by ten before hand and then divide afterwards. You’ll want to check for a decimal place before doing the multiplication, however, since that will break your calculations for whole numbers.