Problem multiplying a double
Hi All,
I have some code where I do something like
for (int i=0;i<11;i++) {
double currentValue = i * 0.01;
System.out.println(currentValue);
The result is
0.09
0.19
0.29
0.39
0.49
0.59
0.690000000000001
0.79
etc.....
How can I prevent the extra decimal points.
I know I could just cat the value to a string and
watch the lenght, then if its too long I can substring
out 4 chars. But I was wondering if I can prevent the
calculation frmo doing this.
Thanks,
Pat
Ok here is the fix, I think people should always post the fix.
Dont forget to import java.text.DecimalFormat
Here is the actual code. The stuff I posted earlier was
a simple example. The actual code is a program that
graphs a curve trace of a diode.
for (int i=0; i < points.size(); i++) {
g.fillRect(i*4+1,12,1,5);
point = (Point)points.get(i);
if (point.x%10 == 0) g.fillRect(i*4+1,6,1,11);
double currentStep = i * currentStepValue;
DecimalFormat df = new DecimalFormat("##0.000");
if (point.x%10 == 0) {
g.drawString(""+df.format(currentStep),i*4+1,10);
}The part that fixes the precision problem is
DecimalFormat df = new DecimalFormat("##0.000");
g.drawString(""+df.format(currentStep),i*4+1,10);
or in the simple example I used the fix is :
for (int i=0;i<11;i++) {
double currentValue = i * 0.01;
DecimalFormat df = new DecimalFormat("##0.000");
System.out.println(df.format(currentStep);
}I hope this helps someone :)
[email protected]
Similar Messages
-
Problem in handling double click in the second alv grid control
Hi all,
I have a screen. In the screen , I have 2 custom container and each custom container has 1 alv grid control.
I need to handle double click event for both of alv grid controls in my screen.
I defined 2 local event handler class for each alv grid and defined 2 handle_double_click event.
In the first Alv grid double click works fine , everything is ok, world is peaceful.
But in the second alvgrid, the row parameters (E_ROW, E_COLUMN, ES_ROW_NO) comes initial so i cannot handle it.
All i need is to call a different transaction (displaying the equipment-IE03) when user double-click on a field in the second alv grid control. I tried to use hotspot_click event too but it does'nt give the row id either.
I read some posts in the forms ([Double click event of alv grid control|Double click event of alv grid control]).
I tried everything but nothing works.
Please help. Your answers will be appreciated.Hello Eagle
I am not sure where the problem lies in your case but sample report ZUS_SDN_THREE_ALV_GRIDS_01 shows that you can always find out the current cell after the double-click event (in any case you have the current cell already as IMPORTING parameters of the event):
*& Report ZUS_SDN_THREE_ALV_GRIDS_01
*& Flow logic of screen '0100' (no screen elements, ok-code => GD_OKCODE):
** PROCESS BEFORE OUTPUT.
** MODULE STATUS_0100.
** PROCESS AFTER INPUT.
** MODULE USER_COMMAND_0100.
*& Thread: problem in handling double click in the second alv grid control
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1172052"></a>
REPORT zus_sdn_three_alv_grids_01.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syst-repid,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_2 TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
go_grid3 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_outtab TYPE STANDARD TABLE OF vbak,
gt_outtab_2 TYPE STANDARD TABLE OF vbap,
gt_outtab_3 TYPE STANDARD TABLE OF vbep.
**PARAMETERS:
** p_bukrs TYPE bukrs DEFAULT '1000'.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
ms_row TYPE lvc_s_row,
ms_col TYPE lvc_s_col.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_outtab TYPE vbak,
ls_outtab_2 TYPE vbap,
ls_outtab_3 TYPE vbep.
" Initialize class data
CLEAR: ms_row,
ms_col.
CASE sender.
WHEN go_grid1.
ms_row = e_row.
ms_col = e_column.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'GET_ITEMS'
* IMPORTING
* rc =
WHEN go_grid2.
ms_row = e_row.
ms_col = e_column.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'GET_SCHEDULE_LINES'
* IMPORTING
* rc =
WHEN go_grid3.
** READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
** CHECK ( ls_vbap-matnr IS NOT INITIAL ).
** SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
** CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM vbak INTO TABLE gt_outtab UP TO 100 ROWS.
PERFORM init_controls.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAK'
CHANGING
it_outtab = gt_outtab
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_outtab_2.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAP'
CHANGING
it_outtab = gt_outtab_2 " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_outtab_3.
CALL METHOD go_grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'VBEP'
CHANGING
it_outtab = gt_outtab_3 " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro:
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "ORDERS"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Refresh display of detail ALV list
CALL METHOD go_grid3->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
" Double-click on first or second ALV grid
WHEN 'GET_ITEMS' OR
'GET_SCHEDULE_LINES'.
PERFORM get_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
* Create 2nd splitter container
CREATE OBJECT go_splitter_2
EXPORTING
parent = go_cell_left
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid3
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
ENDFORM. " INIT_CONTROLS
*& Form GET_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM get_details .
* define local data
DATA: ls_row TYPE lvc_s_row,
ls_col TYPE lvc_s_col.
data: ls_outtab type vbak,
ls_outtab_2 type vbap,
ls_outtab_3 type vbep.
BREAK-POINT.
CASE gd_okcode.
WHEN 'GET_ITEMS'.
CALL METHOD go_grid1->get_current_cell
IMPORTING
* e_row =
* e_value =
* e_col =
es_row_id = ls_row
es_col_id = ls_col
* es_row_no =
read TABLE gt_outtab into ls_outtab index ls_row-index.
refresh: gt_outtab_2,
gt_outtab_3.
SELECT * FROM vbap into TABLE gt_outtab_2
WHERE vbeln = ls_outtab-vbeln.
WHEN 'GET_SCHEDULE_LINES'.
CALL METHOD go_grid2->get_current_cell
IMPORTING
* e_row =
* e_value =
* e_col =
es_row_id = ls_row
es_col_id = ls_col
* es_row_no =
READ TABLE gt_outtab_2 into ls_outtab_2 index ls_row-index.
refresh: gt_outtab_3.
SELECT * FROM vbep into TABLE gt_outtab_3
WHERE vbeln = ls_outtab_2-vbeln
AND posnr = ls_outtab_2-posnr.
WHEN OTHERS.
RETURN.
ENDCASE.
IF ( lcl_eventhandler=>ms_row = ls_row AND
lcl_eventhandler=>ms_col = ls_col ).
MESSAGE 'Current cell identical' TYPE 'I'.
ELSE.
MESSAGE 'Current cell NOT identical' TYPE 'I'.
ENDIF.
ENDFORM. " GET_DETAILS
Regards
Uwe -
Problem with changing double to int!
Hi guys. I've got a major headache trying to solve this problem, and I'm hoping maybe someone abit wiser than I could help me out.
I've added two lots of code, one where if I input 10 as the distance I get an answer of 423.529411..etc. However I want it to display this as just 423seconds. Then print on the next line 'to Travel 10 takes 0 hours, 7mins and 3 seconds. Instead it prints 0.1117etc hours and 7.0574738 minutes and 3.529etc seconds.
public static double enterDistance()
System.out.println("Type the travel distance: ");
distance = UserInput.readDouble();
if (distance < 0)
System.out.println("Illegal Distance Value");
distance = 0;
enterRoadType();
enterDistance();
return distance;
public static void calcTime()
enterRoadType();
time = enterDistance()/speed; // time in secs
tottime = tottime + time; //total time in hours
System.out.println("To travel " + distance + " takes " + (time*60*60) + " seconds");
System.out.println("To travel " + distance +" takes " + time + " hours and " + (time*convert%convert) + " minutes and " + (time *convert*convert%convert) + " seconds");
Totaltime = Totaltime + (time*convert*convert);
Totaldistance = Totaldistance + distance;
}So to try and get it to do what I want, I change this line:
time = enterDistance()/speed; // time in secsto
time = (int)(enterDistance()/speed); // time in secsHowever then it prints that it takes 0 seconds, 0 hours, 0 mins.
Argh I'm so lost.
Any help is appreciatedI see you use (time*60*60) to display your seconds,
this means that time = enterDistance()/speed; // time in secs is actually wrong
So my guess is that you either or using wrong units for your speed or distance.
I think if you try time = (int)(60*60*enterDistance()/speed); you will not get 0 for your time but i would focus on why your seconds arent seconds first -
Problems in CS4: Double entries while indexing
How to prevent double entries from occuring while indexing in CS4, please comment
Audacity
Audacityabout 8
Audacityalign tool 116, 118
Audacityamplify effect 160-162
How to prevent the double entries of Audacity
ThanksIf the cursor is the only problem, my guess is that you haven't updated your video card drivers.
-
Dumb and minor problem...double LibreOffice icons in Xfce menu
not the most serious problem, I know, but in my Xfce application menu, under "Office" I get _two_ icons for some LibreOffice apps...LibreOffice itself, Base, Calc, Impress, and Writer, but not for Draw, Math or QuickStarter.
Any ideas? I don't even know if I can edit the menu "by hand," or what action each represents...any pointers from Xfce users?
thanks,
daveA bit of a guess, but doesn't the menu use the .desktop files? These are found in /usr/share/applications and ~/.local/share/applications.
Check out the contents of those directories and see if there are multiple entries for the apps that are doubled. -
Multiplying two Double values.
I have two double objects.
Double d1 = new Double(1);
Double d2 = new Double(2);
I want to multiply these two values.
How can i do this.
I tried d1.doubleValue() * d2.doubleValue();
It says * is an invalid assignment operator.
Please help.....trydouble foo = d1.doubleValue() * d2.doubleValue();
-
Problem in Catching Double Click
Hi,
I have a JLabel, i override paint method of this label to draw few line, and then i add a mouse listener to this label,
Now i want to capture a double click event, and open a dialog box, when user double clicks
Code i have for it is as below
public void mouseClicked(MouseEvent e)
int i = e.getClickCount();
System.out.println("click count " + i);
if(e.getClickCount() >= 2)
System.out.println("creating instance of CalOverrideAndMaintDialog");
new CalOverrideAndMaintDialog(keyDate, lineNum);
But the problem is, it opens 2 dialog boxes instead of 1, is it to do with speed of mouse, how can i get only 1 dialog box, is there any other better method to do this
PS: i see this ("creating instance of CalOverrideAndMaintDialog"); printed twice
Ashishhi ,
i also wanna to increase the double click speed in my swing application.
In ControlPanel >> Mouse Properties >> there is an option for increasing the double click speed.
Similarly , i need to have a JSlider , getting User Input from the JSilder Object, thereby increasing the double click speed for my Swing Application.
how to do this one in swing ???
Also have a look at :
http://forum.java.sun.com/thread.jsp?forum=57&thread=195316
http://forum.java.sun.com/thread.jsp?forum=57&thread=247776
If u have got any idea,please help me..... -
XP 2000 T-Bred K7T Turbo2 overclocking problem(multiplier)
I've updated the mobo with the Latest BIOS 3.6 and still the multiplier doesn't do what it should do...
I have the new athlon XP 2000+ with Thoroughbred core
512mb PC133 Kingston
when i changed the multiplier to 14 with 133FSB(default)
it gave me 770mhz ... what the? it should be 14x133 = 1862Mhz.
Maximum overclocking i could reach was 150FSB x default multiplier which gave me 1875Mhz. but then it will display artifacts while doing heavy processing tasks and i suspect that those visual artifacts were coming from the overclocked FSB to 150 which will at the same time overclock my memory to PC150( my memory can't handle that!)
My overclocking can only be done correctyl by changing the mobo's FSB which in fact is limited by the VIA chipset controller and my memory overclocking capability.
Any help or fixes will be appreciated.yes, but wicked unstable because of the overclocked agp, the screen would have white rectangles where the ads should be and that kinda thing. by moving down a little at a time, I was able to leave it @150 and have it run fairly well. by changing to my little guy, 1500Xp I was able to squeak a couple of more fsb ,but I still moved it back to 150 ,as that was the sweet spot Funny thing about it was, that I was running 3 different brands of ram, and still could get it up there ,but it was more stable with just 1 stick, and the Kingston was CL2 so I chose that. They weren't expensive ram either, Apacer and Centon from Circuit City. Closer examination of the ram showed up the fact that they were all Infenion chips. I was also using a modified version of 98se that allows up to 1 gb of ram. I have since loaded one with XP and still does excellent @150FSB and 2 sticks 256 Kingston CL2. I was gonna try PC150 but this little test showed that was a waste of money. This was with a FUTUREPOWER400watt P/S I think trying anything bigger would still give you problems as you have no way to lock pci/agp from the OC like a kt3 or KT4 has and hardware don't like OC as 1 dead harddrive will tell you. BIGDADDY51
-
i need help! >: it been weeks
Assuming your Itunes is working without problem, use Windows Explorer, right click the music file and choose "Open With", then "Choose Default Programs...", then Itunes and OK.
-
10.4.6 installed - no problems and no double boot either
I've gotten into the habit of running all major updates from a fresh OS backup on an external FW drive using the combo updates. This allows me to install the update to either drive, in this case the Boot Drive. In the case of this update, I didn't have ANY of the problems or concerns mentioned elsewhere, no dual boot, no extra wait time on boot, no failures, nada.
So, if you haven't purchased an external drive for backup and such here is another great reason to.It's been reported that you will not get the dual boot when using the 10.4.6 Combo. I just ran the update using Software Update and got the dual boot, no problem however, worked great.
Steve M. -
Account problem, please erase double account!
hi, i ve run into major account problems:
now i am logged in as "peppermint". that used to be my account
in 2005, and i posted very rarely.
later i began using my actual account, lot of topics and
i cant login with that cause it does autologin when i log out from "peppermint". (?)
can any admin please erase the account with alias "peppermint"?
thanksHi peppermint!
It isn't necessary to delete the "peppermint" account.
Just delete the browser's Apple Cookies, clear the browser Cache and try again.
ali b -
Probleme création double couche
Bonjour,
Dans Encore CS5, j'ai systématiquement un message d'erreur "accès refusé" lors de la création d'un projet double couche 8.5 go.
Mon projet pèse environ 6go et j'ai plusieurs montages qui devraient permettre à Encore de créer le point d'interruption entre les 2 couches.
Quelqu'un à t'il rencontré ce problème ?
Merci.En fait comme j'ai la chance d'avoir un mac pro avec bootcamp, j'ai réussi à graver ce DVD double couche du côté Mac avec DVD Studio Pro.
Concernant ta suggestion (côté PC) je ne comprends pas très bien ce que signifie relancer en tant qu'administrateur.
Habituellement je n'ai qu'une seule manière de lancer W7. Je ne suis pas très fort pour tout ce qui concerne le système. Si ça peut mettre sur la piste j'ai également déjà gravé du double couche (mais pas en DVD vidéo, mais en DVD de donnée avec Néro) et ça marche très bien. Le seul problème c'est pour un DVD vidéo avec Encore. -
Problem while reading double data?
run the program
then get the output, show below
have an additional data
import java.io.*;
import java.util.*;
import java.net.*;
public class SimpleInputStream
private StringTokenizer tk;
public SimpleInputStream(String fileName) throws IOException
String content = readFile(fileName);
tk = new StringTokenizer(content);
public SimpleInputStream(String fileName, String delim) throws IOException
String content = readFile(fileName);
tk = new StringTokenizer(content, delim);
public static String readFile(String fileName) throws IOException
BufferedReader reader = new BufferedReader(new FileReader(fileName));
StringBuffer buffer = new StringBuffer();
char temp[] = new char[20];
while ( reader.read(temp) != -1)
buffer.append(temp);
if (reader != null)
reader.close();
return buffer.toString();
public int readInt() throws NullContentException
if (!tk.hasMoreTokens())
throw new NullContentException("not more element in content");
return Integer.parseInt(tk.nextToken());
public float readFloat() throws NullContentException
if (!tk.hasMoreTokens())
throw new NullContentException("not more element in content");
return Float.parseFloat(tk.nextToken());
//test if any data can be used
public boolean hasMore()
return tk != null && tk.hasMoreTokens();
public double readDouble() throws NullContentException
if (!tk.hasMoreTokens())
throw new NullContentException("not more element in content");
return Double.parseDouble(tk.nextToken());
public void close()
tk = null;
public static void main(String[] args)
try {
SimpleInputStream input = new SimpleInputStream("resources/c17.txt");
while (input.hasMore())
System.out.println(input.readDouble());
} catch (Exception e) {
e.printStackTrace();
class NullContentException extends Exception
public NullContentException()
super();
public NullContentException(String msg)
super(msg);
}file "resources/c17.txt"
17 11 9 20
1.12
1.12
1.12
1.12
1.12
1.12
1.12
1.12
2.24
2.24
2.24
2.24
2.24
2.24
4.64
4.64
4.64
the output:
17.0
11.0
9.0
20.0
1.12
1.12
1.12
1.12
1.12
1.12
1.12
1.12
2.24
2.24
2.24
2.24
2.24
2.24
4.64
4.64
4.6424 // here the additional data why???
4.64i alway this class to read int data but when i first try to use it to read double data , it is failed, it always generate many other data
-
Problem multiply cells on numbers 08
Hi bit of dumb question but i have just started using my numbers 08(after owning for over a year now) But i am trying to multiply cells,i have changed the formula thing when it comes up and it works,but i keep having to do this every time i would like it to automaticly do it like it does the sum and put it in bottom left corner.Any help will be much appreciated.
Thanyou for taking the time to reply.I have figured out how to do that now, but at the moment i have found that using the product button in functions to be the easiest way but what i am trying to do is
In the bottom left corner of the screen is the symbols sum,avg,min,max and count i want to either change or add one for product so when i highlight across 2 cells it automatic shows the product there so i can grab it and place it in the desired cell the same way i can with sum or count. -
Problems with java.lang.Double in a Pojo
Hi!
I'm getting some problems with a Double (wrapper class) in a sub-report related with a Pojo.
The exception has more than 100 lines.
It's starts with:
at com.crystaldecisions.sdk.occa.report.application.ds.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at br.inf.teorema.javautils.util.CrystalReportsUtils.export(CrystalReportsUtils.java:520)
Caused by: com.crystaldecisions.sdk.occa.report.application.b6: Valor nulo inesperado localizado para o membro Produto.getAliquotaICMS. (UNEXPECTED NULL VALUE ... )
at com.crystaldecisions.sdk.occa.report.application.b6.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.de.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.de.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.de.getDouble(Unknown Source)
and ends with:
[JRCCommunicationAdapter] detected an exception: Erro inesperado do conector do banco de dados (UNEXPECTED ERROR WITH DATABASE CONNECTOR )
at com.crystaldecisions.reports.queryengine.Row.char(Unknown Source)
at com.crystaldecisions.reports.queryengine.Row.getValue(Unknown Source)
at com.crystaldecisions.reports.datalayer.a$d.getValue(Unknown Source)
at com.crystaldecisions.reports.saveddata.saveddata.SavedData.a(Unknown Source)
at com.crystaldecisions.reports.saveddata.a.a(Unknown Source)
at com.crystaldecisions.reports.saveddata.a.a(Unknown Source)
at com.crystaldecisions.reports.basicdataengine.a.p(Unknown Source)
at com.crystaldecisions.reports.basicdataengine.a.a(Unknown Source)
It occurs when my Double has null value. When I put "0.0", there are no problems.
Anyway, in specifics contexts, null != 0.0.
I think it's a bug. Someone encountered the same problem?Sorry for my insistence, but this problem occurs only for me?
I will explain better.
If I have a report that show the value of a Double field, the getter method should be:
public Double getMyField() {
return myField;
But if myField == null, I can't generate the report.
So, I did:
public Double getMyField() {
if (myField == null) {
myField = 0.0d;
return myField;
I wish don't need to do this correction in getter method.
CR do not works this way with Double?
I have tested, and String works fine.
Maybe you are looking for
-
ITunes cannot read ID3 tags written by Perl module MP3::Tag?
Greetings, Just trying to re-arrange ID3 information in a large set of MP3 files. Before I run the following Perl script, iTunes can read the ID3 tagging information. After writing ID3 inform ation to the MP3, iTunes no longer reads any tagging infor
-
External Hard Drive Doesn't Mount on Desktop through FireWire 400
I have an external hard drive that mounts on the desktop when connecting to my iMac via USB, but it fails to appear on the desktop when connecting via FireWire 400. It was glitchy in Tiger as well, and had problems since installing Leopard. I was abl
-
I tried to restore my I Phone today but now its not working. The screen is stuck with the plug in picture, and only allows me to make emergency calls. It says I have no service and I can't use my phone. Why does the device show in the left hand side
-
Material Pair issue in SRM Portal - shopping cart
Hello Experts, When we try to add Pair type material in shopping cart in SRM Sandbox Portal (Material no: 11100000000111) , it is throwing error as " Incomplete items in catalog. Only complete items were transferred" in checkout screen and item is no
-
A new site made possible by unlimited layouts!
Hi everyone, Just wanted to share a new site we took live this week with you all. Thanks to Adobe's new feature of unlimited layouts in web apps, and the new email marketing module funtionality, we were able to pull this off. It wouldn't have been po