Hi All

I need some help with some mathematics and remainders, which might not be that difficult if you know how to handle it

Here is what I want to do and calculate in pbp:

I want to determine the A and N counters from a dual modulus PLL MC145158 for who might be familiar with it, if not:
I receive with serin a value which is 6 digits with 1 decimal point a frequency in Khz with 1 decimal
ex: 433687,5 which is Freq as variable or if easyer 433 (in one variable) , and 6875 in another

So:

Freq = var ??? (because it is bigger than 16bit

I have 3 variable, one is fixed which needs to be calculated as followed:

R = var word (14bit)
R = 800 '(fix value untill now)
N = var word (10bit) 'to be calculated
A = var word (7bit) 'to be calculated
temp var word


here is what I need to do in PBP comming from a original C source:

unsigned long temp,nlong,along
Temp = (501800 - 433687,5) * 800
Nlong = temp/64000
Along = (temp-(Nlong*64000))/1000
N = (unsigned int) Nlong
A= (unsigned int)Along




example: freq is 433,6875 Mhz
temp = (501800 - 433687,5) * 800 = 54490000
Nlong = temp/64000 = 54490000/64000 = 851,40625000 (64000 is a fixed divider ratio)
Along = ((Nlong*64000))/1000 = (0,406250*64000))/1000 = 26 '0,406250 is remainder from 851,406250

result should be:
N = 851 without remainder
A = 26

Anyone who can help me