Cstrike
2010-10-17 11:56:19
I've been trying this math function out of curiosity:
No matter what I do, I can't seem to turn the random integer into an extended, therefore whenever I apply a gaussian function my results always return as 1 or 0 (this was designed to be around 1 and 0… though the only fix I have is to go back and make it between 100 and 0).
Is there a way to use extended from a LongInt? or am I SOL?
EDIT: Should I put a decimal after each number? It seems that if I do y = x/2000, I will always get an integer back.
program new;
function GF (a, b, c, x : Extended) : Extended;
begin
result := a*Pow(2.71828, -(((x-b)*(x-b))/c));
end;
var x, xposi, xpose : Extended;
xposi2 : Integer;
begin
xposi2 := random(100);
writeln (xposi2);
xposi := xposi / 100.5; // are we extended now...?
writeln (xposi);
xpose := xposi/100; // Redundant, ignore me... this was in place before the above function to see if going to ext. was possible
writeln (xpose)
x := GF (1, 0, 0.2, xpose);
writeln (x);
end. No matter what I do, I can't seem to turn the random integer into an extended, therefore whenever I apply a gaussian function my results always return as 1 or 0 (this was designed to be around 1 and 0… though the only fix I have is to go back and make it between 100 and 0).
Is there a way to use extended from a LongInt? or am I SOL?
EDIT: Should I put a decimal after each number? It seems that if I do y = x/2000, I will always get an integer back.