| | |
Converting boolean to integer
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Dec 2004
Posts: 489
Reputation:
Solved Threads: 5
Does this help?
http://forum.java.sun.com/thread.jsp...sageID=1092147
http://forum.java.sun.com/thread.jsp...sageID=1092147
use:
or use function
java Syntax (Toggle Plain Text)
boolean b; int iSomeValue; b=true; if(iSomeValue==0)b=false;
java Syntax (Toggle Plain Text)
boolean intToBool(int iVal) { boolean b=true; if(iVal==0)b=false; return b; }
Last edited by DangerDev; Feb 14th, 2008 at 3:07 am. Reason: uncomlete
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Indian Developer
http://falaque.wordpress.com/
That is a lot more code than is needed. The conversion only needs the evaluation of intVal!=0, so the function reduces to
Java Syntax (Toggle Plain Text)
boolean intToBool(int value){ return (value != 0); }
![]() |
Similar Threads
- Weird Binary to Integer Problem (Java)
- converting python to java (Java)
Other Threads in the Java Forum
- Previous Thread: 2D Java Fireworks Explosion
- Next Thread: I need help making a button for my panel
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui helpwithhomework html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows






