Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | Processor math speed

Discussion forum for the BasicX family of microcontroller chips.

Processor math speed - vtol...@bellsouth.net - Jul 3 7:43:19 2007

I'm am mixing some PWM signals and storing them as global variables (about 50 variables) to be used in different modules.

I can store them as integers, but would like to do some math operations with variables that are singles (probably 30 math operations).

Would it be faster to store the PWM signals as singles, or convert from integers to singles then back to integers when I do the math operations?

Thanks,

Joe



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Processor math speed - Tom Becker - Jul 7 7:37:14 2007


> Would it be faster to store the PWM signals as singles, or convert
from integers to singles then back to integers when I do the math...

Three issues: speed, space and range/resolution:
- obviously, not converting is faster than converting.
- a single is stored as four bytes, an integer as two, so integers
take half the space.
- an integer holds no fraction so you will lose the fraction portion
of each math cycle if you convert the single to an integer, and if the
integer exceeds 16 bits, you've lost that, too.

I would opt for storing your vars as singles.
Tom


(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )