"Cristian Prieto" <cristian(at)clickdiario(dot)com> writes:
> Datum
> repeat_item(PG_FUNCTION_ARGS)
> {
> int num_times;
> num_times = PG_GETARG_FLOAT8(0) * 100;
> PG_RETURN_INT32(num_times);
> }
> # Create or replace function test(float) returns integer as 'test.so'
> language 'c' stable;
"float" is FLOAT4 not FLOAT8 ... your function is picking up some
garbage data.
There might also be some roundoff issues to think about --- I'd be
inclined to add an rint() call, or at least add 0.5 before truncating to
integer.
regards, tom lane