Yeah I've done that some years ago (in C if I'm not mistaking), but it can't be as fast as a native function.