Recent Changes - Search:

Information Foreword What is EJS? Demos/Examples Credits Links Webcasts Installation Download & Install EJS Workspaces Running EJS Conditions of Use Documentation EJS Console EJS Interface Description Panel Model Panel View Panel Deployment Elements Reference User Feedback English | Spanish | ? ? View Edit History Print PDF (back to index) (edit this in the feed-back web form) Title int variables turning into double Type Other Raised by SOLOMON? Date opened Sunday, 22 March 2009 Description 1. In a given equation there are several parameters, some of which are integers type and some are double. When the int type variable is changed by either typing using a slider to vary the int type variable, the fields show a double type.  e.g. if I need to put in 8 atoms in a model the variable is declared as an int N the number of atoms. When this N is varied, the fields display 8.00, and using the slider, the N is displayed as 8.023238374849.  How to control the large number of significant figures? What has to be set in the FORMAT field of a variable? 2. I have a plot for the equation, it works really well.  I have set up a model with some number of atoms and connecting bonds. If I have to vary the parameter number of atoms N=2, the model has to display only two atoms with one interconnecting bond, and if a set N=8 then the diplay will have 8 atoms and seven interconnecting bonds.  Writing a if, for, while statments to display (show) as boolean, produces error, saying that N has to be a boolean and not as type int or double. Importance 4 Proposed solution Urgency 3 Status Closed Resolution Solomon, 1.- If you use a slider to display and edit an integer, I recommend that you first set the Format property of the slider to “0”. This displays the integer with no decimal point and no decimals. Second, I would set the number of ticks so that each tick corresponds to one possible integer number AND the Closest property to true. (Also set the Ticks Format property to “0”.) If you do this, your variable will only receive integer values. (What is the point of setting the value of an int to 3.4?) 2.- Use a switch-case statement. In the (rather silly) example below, n is an integer variable: switch (n) { case 1 : System.out.println (“one”); break; case 2 : System.out.println (“two”); break; case 3 : System.out.println (“three”); break; case 4 : System.out.println (“four”); break; case 5 : System.out.println (“five”); break; case 6 : System.out.println (“six”); break; default : System.out.println (n+” is too high”); break; } (back) « 00027 · Edit Form · 00029 »

Edit - History - Print - Recent Changes - Search
Page last modified on June 07, 2009, at 10:44 PM