Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > io *odio* il C
Pages (2): [1] 2 »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
cato
Wild boys always shine

User info:
Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
io *odio* il C

Manipolazione di bit
percchazzo non funziona?

cioe la versione da sfigato con somme e prodotti va, quella + geek con gli shift no...


code:
/* converto da 8 -> 32 bit */ //dummy=dummy|RX_buffer[3]; //dummy<<8; dummy=(dummy+RX_buffer[3])*256; //dummy=dummy|RX_buffer[2]; //dummy<<8; dummy=(dummy+RX_buffer[2])*256; //dummy=dummy|RX_buffer[1]; //dummy<<8; dummy=(dummy+RX_buffer[1])*256; //dummy=dummy|RX_buffer[0]; dummy=dummy+RX_buffer[0]; fprintf(stdout, "%x \n", dummy);


dove dummy è un 32bit e gli elementi di RX_buffer da 8bit...

grrr non capisco
code:
#include <stdio.h> unsigned long i=0; int main(int argc,char *argv[]) { i=1; printf("%x-->",i); i<<8; printf("%x",i); }


in questo esempio stupido al posto di ottenere 100 ottengo un laconico 1-->1

__________________

code:
  , ,  | | Me@Flickr  [ov0] | | my photo Blog  {| |} |@| Pallavolo La Nuova Rossa Milano --"-"--| | -------| | "If You Can't Open It, You Don't Own It"

07-02-2005 16:08
Click Here to See the Profile for cato Click Here to See the Blog of cato Click here to Send cato a Private Message Visit cato's homepage! Find more posts by cato Add cato to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged


dummy<<8;

i<<8;


Non assegni il valore dei risultati.

Prova con i = i<<8 o con dummy = dummy << 8;

:)

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

07-02-2005 16:14
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
cato
Wild boys always shine

User info:
Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

code:
#include <stdio.h> unsigned long i=0; int main(int argc,char *argv[]) { i=1; printf("%x-->",i); i=i<<8; printf("%x",i); }


ma vaff...
che linguaggio di merda

__________________

code:
  , ,  | | Me@Flickr  [ov0] | | my photo Blog  {| |} |@| Pallavolo La Nuova Rossa Milano --"-"--| | -------| | "If You Can't Open It, You Don't Own It"

07-02-2005 16:15
Click Here to See the Profile for cato Click Here to See the Blog of cato Click here to Send cato a Private Message Visit cato's homepage! Find more posts by cato Add cato to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
jdhoring
Ma saggio de che?

User info:
Registered: May 2003
Posts: 2867 (0.35 al dì)
Location: Milano
Corso: Informatica triennale
Anno: Giurassico
Time Online: 27 Days, 17:36:29 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Prova con un espediente banale:

invece di i<<8 scrivi i=i<<8

Riposta se non funza.

[EDIT] alla mia età i riflessi sono + lenti.... cmq il C è un linguaggio stupendo, basta solo usarlo con la testa (= non usare le abbreviazioni... non dimentichiamo che i sorgenti servono a chi li legge per capirli...)

__________________
Furbo è colui che è molto bravo a togliersi da quei guai in cui il saggio non si sarebbe mai cacciato

Il bravo motociclista è come un buon amante: ha equilibrio, giudizio e tempismo.

Nessuna forma d'amore ha tanto rispetto per la libertà dell'altro come l'amicizia.

Last edited by jdhoring on 07-02-2005 at 16:22

07-02-2005 16:15
Click Here to See the Profile for jdhoring Click Here to See the Blog of jdhoring Click here to Send jdhoring a Private Message Find more posts by jdhoring Add jdhoring to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
cato
Wild boys always shine

User info:
Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

anzi uso <<= che fa figo

__________________

code:
  , ,  | | Me@Flickr  [ov0] | | my photo Blog  {| |} |@| Pallavolo La Nuova Rossa Milano --"-"--| | -------| | "If You Can't Open It, You Don't Own It"

07-02-2005 16:15
Click Here to See the Profile for cato Click Here to See the Blog of cato Click here to Send cato a Private Message Visit cato's homepage! Find more posts by cato Add cato to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by cato
ma vaff...
che linguaggio di merda


Sento le urla di Kernighan e di Ritchie... Stanno venendo a prenderti... :asd:

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

07-02-2005 16:17
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CLod
JAILED

User info:
Registered: May 2002
Posts: 2688 (0.31 al dì)
Location: una delle 2 torri
Corso: Master ICT Sec
Anno: security
Time Online: 14 Days, 23:35:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

usa assembly che è meglio :asd:

__________________
Se il pugno e' chiuso la mano e' vuota. Solo se la mano e' aperta puoi possedere tutto

07-02-2005 16:19
Click Here to See the Profile for CLod Click Here to See the Blog of CLod Click here to Send CLod a Private Message Find more posts by CLod Add CLod to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
cato
Wild boys always shine

User info:
Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by DeepBlue
Non assegni il valore dei risultati.

Prova con i = i<<8 o con dummy = dummy << 8;

:)


:pc: :swear: :pccrash:

ma ca##o mette un warning pareva brutto?

sto iniziando ad apprezzare ADA :look:

__________________

code:
  , ,  | | Me@Flickr  [ov0] | | my photo Blog  {| |} |@| Pallavolo La Nuova Rossa Milano --"-"--| | -------| | "If You Can't Open It, You Don't Own It"

07-02-2005 16:19
Click Here to See the Profile for cato Click Here to See the Blog of cato Click here to Send cato a Private Message Visit cato's homepage! Find more posts by cato Add cato to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
jdhoring
Ma saggio de che?

User info:
Registered: May 2003
Posts: 2867 (0.35 al dì)
Location: Milano
Corso: Informatica triennale
Anno: Giurassico
Time Online: 27 Days, 17:36:29 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by cato
anzi uso <<= che fa figo


eccolo... manco avevo finito di scriverlo..

__________________
Furbo è colui che è molto bravo a togliersi da quei guai in cui il saggio non si sarebbe mai cacciato

Il bravo motociclista è come un buon amante: ha equilibrio, giudizio e tempismo.

Nessuna forma d'amore ha tanto rispetto per la libertà dell'altro come l'amicizia.

07-02-2005 16:23
Click Here to See the Profile for jdhoring Click Here to See the Blog of jdhoring Click here to Send jdhoring a Private Message Find more posts by jdhoring Add jdhoring to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
recoil
dsy adminz

User info:
Registered: Mar 2002
Posts: 4454 (0.51 al dì)
Location: Milano / Erba
Corso: TICOM
Anno: laureato
Time Online: 61 Days, 16:17:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

il problema a volte è proprio del compilatore che rompe le balle con warning sulle conversioni implicite (magari sui puntatori) e poi si dimentica di segnarlare errori come quello o la mancanza del doppio == nelle if e nei cicli, errore che ogni tanto si commette

però il linguaggio è bello

__________________
Sono sempre alla ricerca di curriculum interessanti da segnalare alle società con cui ho contatti. Info in pm

07-02-2005 16:29
Click Here to See the Profile for recoil Click here to Send recoil a Private Message Visit recoil's homepage! Find more posts by recoil Add recoil to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by cato
:pc: :swear: :pccrash:

ma ca##o mette un warning pareva brutto?


Se vuoi farti scassare le palle per ogni puntino sulle i, usa nelle opzioni di compilazione " -Wall ", che attiva TUTTI i warning.

Nel tuo caso ti avrebbe detto: "test.c:7: warning: statement with no effect"

Se vuoi sapere qual è il warning esatto che fa questa cosa, spulcia la man, a memoria non lo ricordo :)

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

07-02-2005 16:38
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
jdhoring
Ma saggio de che?

User info:
Registered: May 2003
Posts: 2867 (0.35 al dì)
Location: Milano
Corso: Informatica triennale
Anno: Giurassico
Time Online: 27 Days, 17:36:29 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by recoil
il problema a volte è proprio del compilatore che rompe le balle con warning sulle conversioni implicite (magari sui puntatori)
KUT


e fa pure bene.... sennò il cast a cosa serve?

__________________
Furbo è colui che è molto bravo a togliersi da quei guai in cui il saggio non si sarebbe mai cacciato

Il bravo motociclista è come un buon amante: ha equilibrio, giudizio e tempismo.

Nessuna forma d'amore ha tanto rispetto per la libertà dell'altro come l'amicizia.

07-02-2005 16:39
Click Here to See the Profile for jdhoring Click Here to See the Blog of jdhoring Click here to Send jdhoring a Private Message Find more posts by jdhoring Add jdhoring to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
recoil
dsy adminz

User info:
Registered: Mar 2002
Posts: 4454 (0.51 al dì)
Location: Milano / Erba
Corso: TICOM
Anno: laureato
Time Online: 61 Days, 16:17:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by jdhoring
e fa pure bene.... sennò il cast a cosa serve?


si certo
ma capita magari di avere un puntatore void e di assegnargli un puntatore a una long word.
il warning c'è ma il programma funziona lo stesso

però ti segnala una cosa del genere (e fa bene) quando manca altre segnalazioni più critiche tipo quella che ho esposto prima. perché non mettono più warnings?

__________________
Sono sempre alla ricerca di curriculum interessanti da segnalare alle società con cui ho contatti. Info in pm

07-02-2005 16:45
Click Here to See the Profile for recoil Click here to Send recoil a Private Message Visit recoil's homepage! Find more posts by recoil Add recoil to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Beh un warning su un cast implicito è sicuramente più utile che uno su un'operazione che non ha effetto.

Anche perché il cast potresti essertelo dimenticato e con i puntatori si rischia sempre di fare casino.


Off-Topic:
sempre a riguardo di casting, se fate una ricerca su it.comp.lang.c troverete un sacco di gente che si incazza a morte quando fate il casting sulle malloc... mi ha sempre divertito questa cosa, soprattutto perché in uni ci tenevano parecchio al casting sulle malloc, anche se di fatto non è strettamente necessario

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

07-02-2005 16:52
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
recoil
dsy adminz

User info:
Registered: Mar 2002
Posts: 4454 (0.51 al dì)
Location: Milano / Erba
Corso: TICOM
Anno: laureato
Time Online: 61 Days, 16:17:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by DeepBlue
Beh un warning su un cast implicito è sicuramente più utile che uno su un'operazione che non ha effetto.


e la if o il ciclo?
uno mette = al posto di == ed è fregato, magari perde un sacco di tempo a capire come mai

Off-Topic:
sempre a riguardo di casting, se fate una ricerca su it.comp.lang.c troverete un sacco di gente che si incazza a morte quando fate il casting sulle malloc... mi ha sempre divertito questa cosa, soprattutto perché in uni ci tenevano parecchio al casting sulle malloc, anche se di fatto non è strettamente necessario


si ho notato che ci sono delle guerre in quel newsgroup sul casting e anche su altri argomenti.
poi ci sono i puristi dell'ANSI C che ti uccidono se fai qualcosa che non è standard :D

__________________
Sono sempre alla ricerca di curriculum interessanti da segnalare alle società con cui ho contatti. Info in pm

07-02-2005 16:56
Click Here to See the Profile for recoil Click here to Send recoil a Private Message Visit recoil's homepage! Find more posts by recoil Add recoil to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 06:03.    Post New Thread    Post A Reply
Pages (2): [1] 2 »   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.221 seconds (72.19% PHP - 27.81% MySQL) con 25 query.