PDA

View Full Version : [C] Numero in formato esponenziale


salvodel
01-12-2008, 16:15
Scusate il titolo criptico ma è possibile fare una operazione del genere:

int c;
c=-2.5374554e-005;
Grazie

british
01-12-2008, 16:27
Credo proprio di sì.
Attento però che c è un int, perciò il valore viene convertito al volo (in questo caso viene troncato a zero).
Può essere che il tuo compilatore ti dia un warning in merito.

ciao!

british

salvodel
01-12-2008, 16:49
Credo proprio di sì.
Attento però che c è un int, perciò il valore viene convertito al volo (in questo caso viene troncato a zero).
Può essere che il tuo compilatore ti dia un warning in merito.

ciao!

british

Sono un pxxxa! La variabile è double però il compilarore mi da warning. Come mai?
Grazie

||ElChE||88
01-12-2008, 16:51
Che warning?

salvodel
01-12-2008, 17:24
Che warning?
main.c(1132) : warning C4552: '-' : operator has no effect; expected operator with side-effect

Credo che siano necessarie le parentesi. Che dite?
If an expression statement has an operator with no side effect as the top of the expression, it's probably a mistake.

To override this warning, put the expression in parentheses.
Faccio cosi:
c=(-2.5374554e-005);

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.