0
How to divide int by 3.5
I have a code that's giving me trouble button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(view v) { String strinput = editText.getText ().toString (); int final_value = Integer.parseInt (strinput); edittext.setText (final_value / 3.5 ); } }}; } } I know it won't accept a double but I need to find a way to make it work. I need to take an int from editText divide it by a final double and display it to textview. for an example.
11 Respuestas
+ 1
Cast your int to double.
+ 1
Both int: No, it's going to be rounded to the lower whole number.
At least one must be float.
+ 1
I think it should work all automatic. But I don't know your graphics library.
It's very probable, try it out.
+ 1
Ok... With C++, it would work. Can't help you.
+ 1
Yes, but it requires JNI -> complicated
0
Will it work as both integers and also work as both doubles?
0
so I can have final_value be a integer and 3.5 be a float? and the integer has to be user input from edittext
0
what if the user inputs 3 or even 4 digits? should I just make a separate button for each digit? or can I make it all automatic
0
(x<<1)//7
0
when I cast integer to double it says double can't be applied to int. I'm using java
0
could c++ be used inside of java