[A83] Re: A call to those who think they know more than me.


[Prev][Next][Index][Thread]

[A83] Re: A call to those who think they know more than me.




Hmm, is this faster? Seems it might be. (Didn't explicitly test this.) Of
course, if you really need it fast, then you could write it in assembly
rather than second guess how the C compiler is going to generate your code.

_inline fixedpoint_t fpm_Ceil(fixedpoint_t fxp) {
	if (fxp <= 0) return fxp & 0xffff0000;
	else return ((fxp - 1) | 0x0000ffff) + 1;
}

_inline fixedpoint_t fpm_Floor(fixedpoint_t fxp) {
	if (fxp >= 0) return fxp & 0xffff0000;
	else return ((fxp - 1) | 0x0000ffff) + 1;
}

-----Original Message-----
From: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org]On Behalf Of Robert M. Proie
Jr.
Sent: Wednesday, July 11, 2001 7:33 PM
To: assembly-83@lists.ticalc.org
Subject: [A83] A call to those who think they know more than me.



//TODO: could be more efficient
_inline fixedpoint_t fpm_Ceil(fixedpoint_t fxp) {
	if (fxp&0x0000ffff) {
		if (fxp<=0) return -(fixedpoint_t)((-fxp)&0xffff0000);
		return (fxp&0xffff0000)+FPM_FROMLONGC(1);
	}
	return fxp;
}
//TODO: could be more efficient
_inline fixedpoint_t fpm_Floor(fixedpoint_t fxp) {
	if (fxp&0x0000ffff) {
		if (fxp<0) return -(long)(((-fxp)&0xffff0000)+FPM_FROMLONGC(1));
		return fxp&0xffff0000;
	}
	return fxp;
}

Can you make these more efficient?




Follow-Ups: References: