cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Pasting Code in Forum

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;

}

 

 

 

 

 

 

0 Likes
6 Replies

If using paste as text, it will parse out certain code, see #include. However, a better method of pasting code to a forum is to use pastebins, which are specifically created for pasting code in forums that don't have the tags. For example: http://pastebin.com/m25bd93fb is the above code(link should last for a month), gives syntax highlighting for various languages. I'd recommend using this over pasting code directly into the forum.
0 Likes

Is there no possibility to add some working

 
tags that preserve indentations and do not add line feeds?

0 Likes

Not sure about the indentations, but if you make sure to select "Do not parse emoticons" it will prevent the forum software from putting in smileys in your code. 🙂

0 Likes

Smiles not so bad as converting standart [ i ] sequence into italic.
0 Likes

Micah,

Please make an arragments to fix the forum to be able to paste a code without an issues, or provide the tool (in text message window, for example) which will help to make it.

Keeping the code for a month is not a good idea at all! I am reading the topics 2 and more months old. Therefore, I will not understand most of the things in "kernel can'ts add 4 number..." thread in August

 

Raistmer, just noticed "do not parse emotions" check box, so it is not an issue.

0 Likes

Originally posted by: CaptainN


Raistmer, just noticed "do not parse emotions" check box, so it is not an issue.


Well, do experiment....

I will post this with "Do not parse emotions" checked.
To close this topic once and for all.

array=some_value;

(should read as array[ i ]=some_value;)

EDIT: well, don't parse emotion tag doesn't influent on this italic tag so this IS issue.
0 Likes