I'm almost finished converting this algorithm to Delphi.
But there is a stupid mistake in my code that I can't find

Probably it is during unaccurate work with data types.
Before last mix(a,b,c) it returns correct b and c but wrong a.
If you wish I can publish my code here.
CU,
uncopyrightable
P.S: sorry for my English.