![]() |
|
|
#12 |
|
Undefined
"The unspeakable one"
Jun 2006
My evil lair
22·1,549 Posts |
I would have thought a simple bitwise and mask would suffice. (1 << bit_num) && the_int
|
|
|
|
|
|
#13 |
|
May 2008
3·5·73 Posts |
You can use the bitwise operator 'and' (&) and a bitmask to test a specific bit.
x & 0x0001 x & 0x0002 x & 0x0004 x & 0x0008 x & 0x0010 etc Or if you want to use a variable to specify the bit, you can use a shift operator (>>). x >> y & 0x0001 |
|
|
|
|
|
#14 |
|
Mar 2007
Austria
2×151 Posts |
It works. Thanks a lot retina & jrk.
If you read this, Xyzzy,can you please rename this thread to "Questions on coding my FFT&LLR implementation"? Thanks, --nuggetprime Last fiddled with by nuggetprime on 2008-09-10 at 17:59 |
|
|
|
|
|
#15 |
|
Mar 2007
Austria
2×151 Posts |
If I compile the following C code and run the program, it doesn't print anything!
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned short apl_uiswap(unsigned short nm)
{
unsigned short buf;
int le;
for (le=0;le>16;le++)
{
printf("HI\n");
}
return 3;
}
int main(int argc, char* argv[])
{
apl_uiswap(43);
}
What the hell is going on here?? ![]()
|
|
|
|
|
|
#16 |
|
Undefined
"The unspeakable one"
Jun 2006
My evil lair
22·1,549 Posts |
One presumes you mean: for (le=0;le<16;le++)
|
|
|
|
|
|
#17 |
|
Mar 2007
Austria
4568 Posts |
Thanks retina.
well, it now prints ![]() But if I print le before the loop, it always prints a somewhat random integer: Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned short apl_uiswap(unsigned short nm)
{
unsigned short buf;
unsigned short le;
printf("%d\n",le);
for (le=0;le<16;le++)
{
printf("HI\n");
}
return 3;
}
int main(int argc, char* argv[])
{
apl_uiswap(43);
}
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned short apl_uiswap(unsigned short nm)
{
unsigned short buf;
unsigned short le;
printf("%d\n",le);
for (le=0;le<16;le++)
{
printf("HI\n");
}
return 3;
}
int main(int argc, char* argv[])
{
apl_uiswap(43);
}
thanks, nuggetprime |
|
|
|
|
|
#18 |
|
Undefined
"The unspeakable one"
Jun 2006
My evil lair
183416 Posts |
Sure it is. You're printing the value of an uninitialised variable, it could be anything. Not until the "le=0" is encountered does le become a known value.
Last fiddled with by retina on 2008-09-13 at 08:50 |
|
|
|
|
|
#19 |
|
Mar 2007
Austria
2·151 Posts |
If I write
Code:
void aplint_init(apl_int pt)
{
pt.dg=(unsigned short*) calloc(1,2);
}
but if I write Code:
#define aplint_init(x) x.dg=(unsigned short *)calloc(1,2) What am i doing wrong? thanks, nugget Last fiddled with by nuggetprime on 2008-09-13 at 09:51 |
|
|
|
|
|
#20 |
|
Mar 2007
Austria
2×151 Posts |
Solved above thing.
The next thing I think i'm not sure about is speed related.If you have a large set of numbers and have to add them, is it then faster or equally fast to directly compute x1+x2+x3... instead of adding a2 to a1, then adding a3 to the result and so on... Nice day, nuggetprime Last fiddled with by nuggetprime on 2008-09-13 at 16:30 |
|
|
|
|
|
#21 | |
|
Undefined
"The unspeakable one"
Jun 2006
My evil lair
22×1,549 Posts |
Quote:
Long answer: Just code up the two methods you propose and see which is faster on your hardware with your data with your set sizes. |
|
|
|
|
|
|
#22 |
|
Mar 2007
Austria
2×151 Posts |
Thanks again retina
.One question more, if I may do some more "spamming" here: I'm not able to get long double precision. If I run: Code:
#include <stdio.h>
int main()
{
long double c;
c=1/7.0;
printf("%3.30Lf\n",c);
return 0;
}
Code:
0.142857142857142849212692681249 Thanks, nuggetprime |
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Anyone know enough about coding to do this? | jrafanelli | Software | 2 | 2018-01-11 15:16 |
| Python Coding Help? | kelzo | Programming | 3 | 2016-11-27 05:16 |
| Zhang's OPQBT coding help? | flouran | Programming | 0 | 2009-07-25 02:43 |
| coding midlet for TF | starrynte | Programming | 1 | 2008-12-30 22:31 |
| Coding Challenges | R.D. Silverman | Programming | 18 | 2005-08-09 13:14 |