Influenced by Pascal...
-
Strangly you did nearly hit on the joke - but seems sarcastic humour does not translate over the water well… think Monty Python
-
mxsscott - for your curiosity - a nice compiler should be happy with both. Personally i do not like gcc (totally biased) but should perform ok for this task.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 #include <stdio.h>
2
\ In section .text, align 4, keep-with-next
3 bool is_neg(long x) { return (x < 0); }
\ _Z6is_negl:
\ 00000000 A00FA0E1 LSR R0,R0,#+31
\ 00000004 1EFF2FE1 BX LR ;; return
4
\ In section .text, align 4, keep-with-next
5 int main()
6 {
\ main:
\ 00000000 01402DE9 PUSH {R0,LR}
7 int test_seed = 10000;
8 int test_result;
9
10 test_result= is_neg(test_seed);
11 printf("Result is %i",test_result);
\ 00000004 0010A0E3 MOV R1,#+0
\ 00000008 0C009FE5 LDR R0,??main_0 ;; `?<Constant "Result is %i">`
\ 0000000C ........ BL printf
12 return 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 0050BDE8 POP {R12,LR}
\ 00000018 1EFF2FE1 BX LR ;; return
\ ??main_0:
\ 0000001C ........ DC32 `?<Constant "Result is %i">`
13 }
\ In section .rodata, align 4
\ `?<Constant "Result is %i">`:
\ 00000000 526573756C74 DC8 "Result is %i"
\ 206973202569
\ 00
\ 0000000D 000000 DC8 0, 0, 0
Maximum stack usage in bytes:
Function .cstack
-------- -------
is_neg(long) 0
main() 8
Section sizes:
Function/Label Bytes
-------------- -----
is_neg(long) 8
main() 32
?<Constant "Result is %i"> 16
16 bytes in section .rodata
40 bytes in section .text
40 bytes of CODE memory
16 bytes of CONST memory
Errors: none
Warnings: none///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 #include <stdio.h>
2
\ In section .text, align 4, keep-with-next
3 int is_neg(long n) {return((n&0x80000000)>>31);}
\ _Z6is_negl:
\ 00000000 A00FA0E1 LSR R0,R0,#+31
\ 00000004 1EFF2FE1 BX LR ;; return
4
\ In section .text, align 4, keep-with-next
5 int main()
6 {
\ main:
\ 00000000 01402DE9 PUSH {R0,LR}
7 int test_seed = 10000;
8 int test_result;
9
10 test_result= is_neg(test_seed);
11 printf("Result is %i",test_result);
\ 00000004 0010A0E3 MOV R1,#+0
\ 00000008 0C009FE5 LDR R0,??main_0 ;; `?<Constant "Result is %i">`
\ 0000000C ........ BL printf
12 return 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 0050BDE8 POP {R12,LR}
\ 00000018 1EFF2FE1 BX LR ;; return
\ ??main_0:
\ 0000001C ........ DC32 `?<Constant "Result is %i">`
13 }
\ In section .rodata, align 4
\ `?<Constant "Result is %i">`:
\ 00000000 526573756C74 DC8 "Result is %i"
\ 206973202569
\ 00
\ 0000000D 000000 DC8 0, 0, 0
Maximum stack usage in bytes:
Function .cstack
-------- -------
is_neg(long) 0
main() 8
Section sizes:
Function/Label Bytes
-------------- -----
is_neg(long) 8
main() 32
?<Constant "Result is %i"> 16
16 bytes in section .rodata
40 bytes in section .text
40 bytes of CODE memory
16 bytes of CONST memory
Errors: none
Warnings: none
-
@Helix said:
Strangly you did nearly hit on the joke - but seems sarcastic humour does not translate over the water well… think Monty Python
Ahh, but it was I who was joking all along! I only pretended to take your comments seriously so you would be lulled in to a false sense of security and forced to show your hand!
Guffaw! Guffaw guffaw!
-
ah bollox - and yet no wooden tables
-
@Helix said:
Strangly you did nearly hit on the joke - but seems sarcastic humour does not translate over the water well… think Monty Python
I'm still not 100% convinced that you started out joking, which frightens me. Consider using the </sarcasm> tag in the future. Or, even better, how about a TagException tag for sarcasm, like this one:
-
i thought it was only the admins that can modify tags?
-
@Helix said:
i thought it was only the admins that can modify tags?
Umm, yeah, sure. But, like, I'm totally an admin. And I just gave you ability...?
-
@bstorer said:
Umm, yeah, sure. But, like, I'm totally an admin. And I just gave you ability...?
plz send t3h codez. kthxbai.
-
-
@morbiuswilters said:
It's simple. Just put $admin = true; in every post.@bstorer said:
Umm, yeah, sure. But, like, I'm totally an admin. And I just gave you ability...?
plz send t3h codez. kthxbai.
-
$admin = true
-
-
Is_neg obviously must be optimized for execution time. Here is my proposal:
#define IS_NOT_NEGATIVE 1
#define IS_NEGATIVE 0
#define IS_ZERO_NEGATIVE 0
global int type_o[1<<32];
void prepare_is_neg() {
long n;
int d=IS_NOT_NEGATIVE; // Setup d as positive
// Is 0 negative!!??
type_o[0] = IS_ZERO_NEGATIVE;
for(n=1;n!=0;n++<<0) {
type_o[n] = d;
if(n==2147483647)
d = IS_NEGATIVE; // Now flip d
}
}
int is_neg(long neg) { return type_o[neg]; } // Optimized for time and line space.
-
-
@morbiuswilters said:
@ender said:
Why would C++ be necessary for WTFs?
C++ doesn't create WTFs, it only attracts them. The hope is that one day the C++ spec becomes so massive that all WTFs are contained therein and it can then be nuked from orbit.
Ahem ... let's nuke Redmond first and bazoom!!! no more VB !!!
-
@cklam said:
Ahem ... let's nuke Redmond first and bazoom!!! no more VB !!!
So you ignored the dates in this thread AND my appeal to the last person to not resurrect dead threads?