Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78257152
main.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 19, 11:09
Size
792 B
Mime Type
text/x-c
Expires
Wed, Aug 21, 11:09 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20016656
Attached To
rGEAR Gear
main.c
View Options
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define boxSize_X 1
#define boxHalf_X 0.5
#define NGB_PERIODIC_X(x) (xtmp=(x),(xtmp>boxHalf_X)?(xtmp-boxSize_X):((xtmp<-boxHalf_X)?(xtmp+boxSize_X):xtmp))
#define NGB_PERIODIC_FLAG_X(x) (xtmp=(x),(xtmp>boxHalf_X)?(1):((xtmp<-boxHalf_X)?(1):0))
#define NGB_PERIODIC_SIGN_X(x) (xtmp=(x),(xtmp>boxHalf_X)?(-1):((xtmp<-boxHalf_X)?(1):0))
int main()
{
double p,c;
double d;
double xtmp;
int flag;
int sign;
c = 0.9;
p = 0.1;
printf("%f\n",p-c);
d = NGB_PERIODIC_X(p - c);
printf("%f\n",d);
flag = NGB_PERIODIC_FLAG_X(p - c);
printf("%d\n",flag);
sign = NGB_PERIODIC_SIGN_X(p - c);
printf("%d\n",sign);
}
Event Timeline
Log In to Comment