MicahVillmow

Pasting Code in Forum

Discussion created by MicahVillmow on Jun 30, 2009
Latest reply on Jul 5, 2009 by Raistmer
Please use 'Paste From Word' button

Just cutting and pasting code to the forum can cause issues.

Code that is simply pasted with Ctrl + V:

 

 

#include <CL/cl.h>

#include <stdio.h>

#include <stdlib.h>

typedef unsigned int uint;

typedef unsigned long long ulong;

int cast_test(ulong a) {

float b = (float)a;

float c = __cast_ulong_float(a);

int d = *(int*)&b;

int e = *(int*)&c;

if (d == e) {

return 1;

} else {

fprintf(stderr," Input: %ld CPU: %lf(%x) CL: %ld(%x)\n", a, b, d, c, e);

return 0;

}

}

 

int main(void)

{

ulong correct, incorrect, total, x;

correct = incorrect = total = 0;

for (x = 0; x < (ulong)-1; ++x) {

        correct += cast_test(x);

total++;

}

fprintf(stderr, "%ld correct out of %ld\n", correct, total);

return EXIT_SUCCESS;

}

 

Code that is pasted from 'Paste from Word':

 

#include <CL/cl.h>

#include <stdio.h>

#include <stdlib.h>

typedef unsigned int uint;

typedef unsigned long long ulong;

int cast_test(ulong a) {

float b = (float)a;

float c = __cast_ulong_float(a);

int d = *(int*)&b;

int e = *(int*)&c;

if (d == e) {

return 1;

} else {

fprintf(stderr," Input: %ld CPU: %lf(%x) CL: %ld(%x)\n", a, b, d, c, e);

return 0;

}

}

 

int main(void)

{

ulong correct, incorrect, total, x;

correct = incorrect = total = 0;

for (x = 0; x < (ulong)-1; ++x) {

        correct += cast_test(x);

total++;

}

fprintf(stderr, "%ld correct out of %ld\n", correct, total);

return EXIT_SUCCESS;

}

 

 

 

 

 

Code that is pasted with the 'Past as Plain Text':
#include

 

#include

#include

typedef unsigned int uint;

typedef unsigned long long ulong;

int cast_test(ulong a) {

float b = (float)a;

float c = __cast_ulong_float(a);

int d = *(int*)&b;

int e = *(int*)&c;

if (d == e) {

return 1;

} else {

fprintf(stderr," Input: %ld CPU: %lf(%x) CL: %ld(%x)\n", a, b, d, c, e);

return 0;

}

}

 

int main(void)

{

ulong correct, incorrect, total, x;

correct = incorrect = total = 0;

for (x = 0; x < (ulong)-1; ++x) {

correct += cast_test(x);

total++;

}

fprintf(stderr, "%ld correct out of %ld\n", correct, total);

return EXIT_SUCCESS;

}

 

 

 

 

 

 

Outcomes