Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 31st March 2008, 02:44 AM   #1
Default math.h and lib for BoostC?

I keep needing things like abs().
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 31st March 2008, 05:23 AM   #2
Default

Quote:
Originally Posted by futz
I keep needing things like abs().
Never tried BoostC but from what I find with Google (mostly old forum posts) it looks like it might be a roll-your-own situation. Or maybe you could copy some of the headers and libs from libc (do you have Linux?).

Code:
int abs(int n) {
    return n > 0 ? n : -n;
}
Torben

[Edit: You can browse the libc code here: http://sourceware.org/cgi-bin/cvsweb...?cvsroot=glibc ]

Last edited by Torben; 31st March 2008 at 05:26 AM.
Torben is offline  
Old 31st March 2008, 05:45 AM   #3
Default

Quote:
Originally Posted by Torben
Never tried BoostC but from what I find with Google (mostly old forum posts) it looks like it might be a roll-your-own situation.
I was starting to get that idea anyway, judging by the posts on SourceBoost's forums. Shouldn't be that hard to write one anyway.

It's been many many years since I built my own libs for C. I'll have to refresh my foggy old memory.

Quote:
Or maybe you could copy some of the headers and libs from libc (do you have Linux?).
Good idea. I have almost nothing but Linux. There's windoze on only a few of my too many computers.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 31st March 2008 at 08:33 AM.
futz is offline  
Old 31st March 2008, 06:29 AM   #4
Default

Quote:
Originally Posted by Torben
Code:
int abs(int n) {
    return n > 0 ? n : -n;
}
Thank you Torben for the abs()! I should have known it would be that simple. My Bresenham line routine now works perfect. Building some nice demos for the site.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Reply

Tags
boostc, lib, mathh

Thread Tools
Display Modes




All times are GMT. The time now is 05:11 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker