Jump to content

operações matemáticas com strings


lamuria
 Share

Recommended Posts

boas

programo ha muito pouco tempo, e gostava de saber se há alguma maneira de fazer operações matemáticas com strings.

tanto operações básicas como somas, multiplicações etc etc como mais complexas do tipo logaritmos, expoentes etc etc (nestes últimos posso utilizar a classe math? ou a class math não funciona com strings?)

obrigado pelas respostas

Link to comment
Share on other sites

Operações matemáticas com strings?

As strings são texto. Não dá para fazer operações matemáticas.

O q podes é transformar strings q contenham valores numericos no tipo respectivo e aí sim fazer as contas.

Ex:

String a = "10";
String b = "10";

int x = Integer.ParseInt(a);
int y = Integer.ParseInt(b);

int res = x + y;

Matraquilhos para Android.

Gratuito na Play Store.

https://play.google.com/store/apps/details?id=pt.bca.matraquilhos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.