The error was with the ORIGINAL posting which stated that 2^5 is the same as 2 >> 5. It's not. And neither is 2<<5. QED. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors > -----Original Message----- > From: rolf.freitag@rolf... [mailto:rolf.freitag@rolf...] > Sent: 11 May 2005 15:16 > To: msp430@msp4... > Subject: RE: [msp430] BIG problems with math.h > > Hi, > > > Ahh, 2>>5 == 0. That's not right. > > > > Umm, 2 << 5 = 2*2^5 = 2^6 = 64. That's not right either. > > what's wrong with these? > I can find no error. In ANSI-C they are both right. > > Regards, > > Rolf > > > > > > > . > > > Yahoo! Groups Links > > > > > > > >
BIG problems with math.h
Started by ●May 11, 2005
Reply by ●May 11, 20052005-05-11
Reply by ●May 11, 20052005-05-11
Hi,
> Ahh, 2>>5 == 0. That's not right.
>
> Umm, 2 << 5 = 2*2^5 = 2^6 = 64. That's not right either.
what's wrong with these?
I can find no error. In ANSI-C they are both right.
Regards,
Rolf
Reply by ●May 12, 20052005-05-12
Hi, > I have few questions, may I ask? > > >> Ahh, 2>>5 == 0. That's not right. > how much will be here then? 2 >> 5 is zero. > >> But, 2^5 == 32 == 1 << 5. That is right. :-) > so, on mspgcc I can use sipmly 2^5 and the result will be 32? > why then 1 << 5 is 32 too? how is it? 2^5 in C is (in fact) 7. 2 to the power of 5 is 64. That's the same as 1 << 6. Perhaps this is not the list for you. Get a good book on C. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors
Reply by ●May 12, 20052005-05-12
hi, I have few questions, may I ask? >> Ahh, 2>>5 == 0. That's not right. how much will be here then? >> But, 2^5 == 32 == 1 << 5. That is right. :-) so, on mspgcc I can use sipmly 2^5 and the result will be 32? why then 1 << 5 is 32 too? how is it? > Looks like in the latest mspgcc distribution you can get something > linked like this: > > msp430-gcc foo.c -Wl,-mmsp430x1611 -lm -lfp > > So, if foo.c uses sin() then it all gets linked up hunkey dorey. > > If, however, you need 64-bit doubles for sin() then it looks like you're > out of luck. I have the latest mspgcc version. in dev-cpp I've added -lm but its still dont work. You have said smth about fdlibm, how to implement it? will it help? How to link math.h? Im noobie, so don't know all of these specific things. One more thing. I have a Taylor line, it counts smth and then I get a number which i need to send to DAC (convert to voltage), so I understand, that I need decimal number convert to hex, right? How can I make it by writing my own function or mspgcc have own? ps. im using F169.
Reply by ●May 12, 20052005-05-12
Sorry but 2 to the power of 5 is 32 not 64 which are the same as 1<<5. Sorry Paul but I must take my revenge since I pay a little bit more attention to these details now ;) Fred ------------------------------- Frederic Beaulieu, M.Sc. Research and Development NewTrax Technologies Inc. http://www.newtraxtech.com/ -----Original Message----- From: msp430@msp4... [mailto:msp430@msp4...] On Behalf Of Paul Curtis Sent: Thursday, May 12, 2005 5:48 AM To: msp430@msp4... Subject: RE: [msp430] BIG problems with math.h Hi, > I have few questions, may I ask? > > >> Ahh, 2>>5 == 0. That's not right. > how much will be here then? 2 >> 5 is zero. > >> But, 2^5 == 32 == 1 << 5. That is right. :-) > so, on mspgcc I can use sipmly 2^5 and the result will be 32? > why then 1 << 5 is 32 too? how is it? 2^5 in C is (in fact) 7. 2 to the power of 5 is 64. That's the same as 1 << 6. Perhaps this is not the list for you. Get a good book on C. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors . Yahoo! Groups Links -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.8 - Release Date: 5/10/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 5/12/2005
Reply by ●May 12, 20052005-05-12
Hi Fred, Ahh, sorry. Yes, 2**5 is indeed 32 which is 1<<5. Anyway, the way to compute this in C is using pow, powf, or if you have it ipow. -- Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors > -----Original Message----- > From: Frederic Beaulieu [mailto:fbeaulieu@fbea...] > Sent: 12 May 2005 12:39 > To: msp430@msp4... > Subject: RE: [msp430] BIG problems with math.h > > Sorry but 2 to the power of 5 is 32 not 64 which are the same as 1<<5. > Sorry Paul but I must take my revenge since I pay a little > bit more attention to these details now ;) > > Fred > > ------------------------------- > > Frederic Beaulieu, M.Sc. > > Research and Development > > NewTrax Technologies Inc. > > http://www.newtraxtech.com/ > > > -----Original Message----- > From: msp430@msp4... [mailto:msp430@msp4...] > On Behalf Of Paul Curtis > Sent: Thursday, May 12, 2005 5:48 AM > To: msp430@msp4... > Subject: RE: [msp430] BIG problems with math.h > > Hi, > > > I have few questions, may I ask? > > > > >> Ahh, 2>>5 == 0. That's not right. > > how much will be here then? > > 2 >> 5 is zero. > > > >> But, 2^5 == 32 == 1 << 5. That is right. :-) > > so, on mspgcc I can use sipmly 2^5 and the result will be 32? > > why then 1 << 5 is 32 too? how is it? > > 2^5 in C is (in fact) 7. 2 to the power of 5 is 64. That's > the same as > 1 << 6. > > Perhaps this is not the list for you. Get a good book on C. > > -- > Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk > CrossWorks for MSP430, ARM, AVR and (soon) MAXQ processors > > > . > > > Yahoo! Groups Links > > > > > > > > -- > No virus found in this incoming message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.11.8 - Release Date: 5/10/2005 > > > -- > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.308 / Virus Database: 266.11.9 - Release Date: 5/12/2005 > > > > > . > > > Yahoo! Groups Links > > > > > > > >