Adding two double's together??
Hi,
I want to add two prices which are Strings to start off with and to get the end calculation in J2ME.
As I can't parse the string into a double, how do I go about doing all of this (String -> double -> end result which is the addition fo the two prices?
i.e. �12.50 + �13.50 = calculatedResult ??
Any help would be appreciated,
Harry
Hi again,
I have another problem. If a value comes in for example at �1.995 and say is added to a value �0.005, how can this be dealt with when rounding up? This needs to go to �2 but using the code you provided will only get me to �10.95.
I have to handle cases where the value may come at �1.995, �1.996, �1.997, �1.998 and �1.999. Each of these 5 values will be added to �0.005 and I really need the addition of the 2 values to be rounded properly. i.e. if �1.996 is added to �0.005 then the resultant answer is �2.00 and not �2.001. The last case �1.999 + �0.005 will come to �2.004 so the half pence will never become a full pence if you understand what I'm saying...? But �9.999 + �0.005 will become �10.004 so the pound has changed here and will need to be dealt with.
Please help!
Similar Messages
-
Adding two double numbers is a problem
Hi friends..
when we try to add the two double numbers say,
119.52, 10.00
here we should get 129.52
but it is giving as 129.51999999999998
Here i want to round this to two digits after decimal point
if i round the above value i will get 129.52 and the problem will be solved.
But we don't know exactly on what basis we are getting the sum as 129.51999999999998.
Assume that, tomorrow when we are adding some other numbers we may got like
129.51444444444448
when we round this we get 129.51
but actually we have to get 129.52.
If anyone know why the system is giving that wrong sum amount, please give solution to avoid this.
To solve this problem, i tried by converting the double numbers to integers and adding these integers and finally converting the sum into double...like
if
d1= 119.52
d2=10
int x = (int)(119.52*100.00);
int y = (int)(10.00*100.00);
int z = x + y;
double d = (double)(z)/100;
This is working for this case...
But when we are applying this approch to other numbers it is giving problem....
i.e, if i convert like below
int x = (int)(72.46*100.00);
this should give x=7246
but it is giving x=7245
What is the solution for this problem...please give immediate reply.....Assume that, tomorrow when we are adding some other
numbers we may got like129.51444444444448
That isn't going to happen. The numerical computations are deterministic. The problem lies in your understanding of how numbers work.
This has been repeated before so if you want more detail I suggest you search the forums for discussion on precision and double.
Computers store numbers in binary. The number you are trying to represent is a decimal number. This produces an error in precision.
The same problem exists in decimal notation. Decimal notation can not accurately represent one divided by three (in decimal 0.33333333.....). -
Adding two time figures together
Please forgive me I am not familiar with FormCalc or Javascript.
I am creating a form for work and I need to add two time figures minutes and seconds (IE 02:30 + 02:30) I have looked all over the web and I can not find anything that is working,
I can add the two figures together but I get (ie 4:60)
please any help you can give will be be wonderfulHi Chris,
No need to shout.
Formula in column C (calculates the Duration (time elapsed) between two Date and Time values:
=B-A
Formula in column D (Calculates the same Duration as above, but subtracts 30 minutes if the total Duration is greater than 5 hours):
=IF(DUR2HOURS(B-A)>5,B-A-DURATION(,,,30,,),B-A)
Note that any cell displaying a Date or a Time (of day) or both contains a Date and Time value.
If only the Date has been entered, the time part is set to 00:00:00 (midnight, at the beginning of that day).
If only the Time has been entered, the date part is set to the date the entry was made.
In the table above, the values in Row 18, the bottom row of the table are as follows:
A18: March 1, 2012 11:00:00 AM
B18: March 1, 2012 5:00:00 PM
C18: 6h
D18: 5h 30m
The first two are Date and Time values, the second two are Duration values.
Regards,
Barry -
Adding two array lists together and a text file to an array list
I'm having problems coding these two methods... Could someone explain how to do this? I can't find information on it anywhere... :(
"MagazineList" is the class I'm coding in right now, and I already declared "list" as an array list of another class called "Magazine".
public boolean addAll(MagazineList magazines)
if (list == magazines) {
return false;
else {
list.addAll(magazines);
return true;
public boolean addAll(String filename)
Scanner in = ResourceUtil.openFileScanner(filename);
if (in == null) {
return false;
String line = source.nextLine();
while (!line.equals("")) {
list.add(Magazine(source));
in.close();
}I assume "addAll(MagazineList magazines)" is defined in the MagazineList class?
Then,
list.addAll(magazines);probably needs to be something like:
list.addAll(magazines.list);This uses the private variable ( should be private) list from the input MagazineList, and adds all of those Magazine objects to the list in the current MagazineList.
But, yes, describe your problems more clearly, and you'll get better answers more quickly (because people will be able to understand you and give you a suggestion without asking you another question first). -
Adding two parsed values together
Why does the following code give me an error of "invalid token +":
String a = "100";
String b = "200";
double sum = Double.parseValue(a) + Double.parseValue(b);I am using Eclipse 3.1 --
I seems to be an eclipse debug error. If Iclick on
Double.parseDouble(a) + Double.parseDouble(b); and Iclick inspect or I try viewing the value in the Display window - I get the above error. However, when I run my code, it seems to work fine.
Thanks for everyones help - -
Adding two time periods together, summing it up and misusing 30 minutes from it HELP!
SUPer tricky questions and brownie points for who can solve it!
Column B6 has 11:00 am, Column C6 has 1:00 pm, column D6 has the total hours calculated (i.e. work from 11:00 am to 1:00 pm = 2 hours) and i want column e6 to minus half an hour (.30 hours) and display -.30 OR minus .30 minutes from Colulmn D6... however, only if the total hours/time in column D6 is greater than 5 hours. PLEASE FOR THE LOVE OF GOD TELL ME THE FORMULA FOR THIS!!Hi Chris,
No need to shout.
Formula in column C (calculates the Duration (time elapsed) between two Date and Time values:
=B-A
Formula in column D (Calculates the same Duration as above, but subtracts 30 minutes if the total Duration is greater than 5 hours):
=IF(DUR2HOURS(B-A)>5,B-A-DURATION(,,,30,,),B-A)
Note that any cell displaying a Date or a Time (of day) or both contains a Date and Time value.
If only the Date has been entered, the time part is set to 00:00:00 (midnight, at the beginning of that day).
If only the Time has been entered, the date part is set to the date the entry was made.
In the table above, the values in Row 18, the bottom row of the table are as follows:
A18: March 1, 2012 11:00:00 AM
B18: March 1, 2012 5:00:00 PM
C18: 6h
D18: 5h 30m
The first two are Date and Time values, the second two are Duration values.
Regards,
Barry -
Adding two special double numbers
Adding two double numbers.
say, 12543.34 and 42895.00 am getting in the decimal part .3999999.
Now I want .34 instead .399999 and how??
Can any body help me ??Read this (or search the forums--this question is asked at least once a day):
http://docs.sun.com/source/806-3568/ncg_goldberg.html -
Adding 2 doubles together yields incorrect results
I have a problem with adding 2 doubles to produce a running total where it appears to also add 0.0000000000000(1 to 9).
The code illustrates my problem and is causing a big issue, I have found references to fix this which use BigDecimal but I want to now what is going wrong.
public class Test1
public static void main(String args[])
String strValue = "";
double dTotal = 0;
double dTotalOLD = 0;
dTotalOLD = dTotal;
strValue = "0.0252154";
dTotal = dTotal + (Double.parseDouble((String)strValue));
System.out.println(dTotalOLD + " + " + strValue + " = " + dTotal);
dTotalOLD = dTotal;
strValue = "0.0250356";
dTotal = dTotal + (Double.parseDouble((String)strValue));
System.out.println(dTotalOLD + " + " + strValue + " = " + dTotal);
System.out.println("dTotal = " + dTotal);
Actual Results =
0.0 + 0.0252154 = 0.0252154
0.0252154 + 0.0250356 = 0.050251000000000004
dTotal = 0.050251000000000004
Expected Results =
0.0 + 0.0252154 = 0.0252154
0.0252154 + 0.0250356 = 0.050251
dTotal = 0.050251
In the main application I upload a file and sum the items for validation but most of the time the total is not what I expect.
What am I doing wrong?
MarkIf you really absolutely need exact results, use BigDecimals.
With doubles, not even 0.1 is exactly 1/10. The IEEE double value closest to 0.1 is approximately 0.1+5.5511*10^-18 -- there is a slight, but significant difference. In calculations these "representation errors" along with others accumulate and eventually can give you relative errors of significant magnitude, although most of the time they stay under 10^-14, 10^-15 -
Adding every other field of two separate rows together.
Hi,
We're using Oracle 11.1.
I's like to add two rows from two different queries together,
I'd like it to look something like:
with
a as
( select 'a' q,'b' r,'c' s,'d' t,'e' u from dual),
b as
( select '1' q, '2' r,'3' s,'4' t,'5' u from dual)
select a.q, b.r, a.s, b.t, a.u from a, b;The trouble is I'm already using WITH and both the 'real queries' get their data from the progressive WITH statements already up top.
I'd like to add every other field from each query to a result row.
I have to use only SQL.
Is there a way I can use UNION and combine the rows using dummy fields for the fields I don't want to use?
Some something like
I know this isn't right but...it sort of what I want to do.
select * from
( select 'a' q,' ' r,'c' s,' ' t,'e' u from dual
union
select '1' q, '2' r,' ' s,'4' t,' ' u from dual);Anybody?Can u try using join.
select a.q, b.r, a.s, b.t, a.u from
(select 'a' q,'b' r,'c' s,'d' t,'e' u from dual) as a,
( select '1' q, '2' r,'3' s,'4' t,'5' u from dual) as b;
This will result in a Cartesian join, but if you have a common column between a & b, then you can use it in the where clause. -
Two graphics card together (eGPU)
Hi everyone,
I'm trying to use two video cards together. I don't want to switch between / use only one of them... both should be ON at the same time. The first one is an Intel integrated GPU and the second one is a Nvidia Quadro NVS 450. The integrated should display only laptop LCD screen and the eGPU Nvidia should display 2 DisplayPort external monitors.
xf86-video-nouveau is installed with everything related to Intel GPU and i'm running default kernel 3.12.0-1. i915 and nouveau are added to MODULES inside /etc/mkinitcpio.conf and vmalloc=512MB added to Grub command line.
Firstly I followed instructions from here : http://superuser.com/questions/117239/h … k-on-linux
Now here I am, both of them are detected with lspci :
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)
08:00.0 VGA compatible controller: NVIDIA Corporation G98 [Quadro NVS 450] (rev a1)
And that should work ! But not at all :-( The computer starts but external monitors (plugged on Nvidia card) stay black/off.
And xrandr doesn't show the second screen :
$ xrandr
Screen 0: minimum 320 x 200, current 1280 x 2720, maximum 32767 x 32767
LVDS1 connected 1280x800+0+1920 (normal left inverted right x axis y axis) 261mm x 163mm
1280x800 60.2*+ 50.0
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
Here is my X11 config files :
20-graphics.conf
Section "Device"
Identifier "IntelCard"
Driver "intel"
BusID "PCI:0:2:0"
Option "AccelMethod" "sna"
Option "DRI" "true"
Option "SwapbuffersWait" "false"
#Option "Shadow" "True"
#Option "TearFree" "true"
EndSection
Section "Device"
Identifier "NvidiaCard"
Driver "nouveau"
BusID "PCI:8:0:0"
Option "GLXVBlank" "true"
EndSection
30-monitor.conf
Section "Screen"
Identifier "Screen0"
Device "IntelCard"
#Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Virtual 3840 2720
EndSubSection
EndSection
Section "Screen"
Identifier "Screen1"
Device "NvidiaCard"
#Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Virtual 3840 2720
EndSubSection
EndSection
Section "Monitor"
Identifier "Monitor0"
Option "Enable" "true"
EndSection
Section "Monitor"
Identifier "Monitor1"
Option "Enable" "true"
EndSection
Section "Monitor"
Identifier "Monitor2"
Option "Enable" "true"
EndSection
What's wrong please? Is anobody can help?
Thanks
Edit : Nvidia card is connected trough this PCI > ExpressCard adapter.
Last edited by hansi (2013-12-06 21:45:28)clfarron4 wrote:So... How is your set-up working if the card isn't inside the laptop?
I use a PCI Express adapter connected through the ExpressCard slot : http://www.mfactors.com/pe4h-ec060a-v2- … d-adapter/
ANOKNUSA wrote:but you may be able to use a xorg.conf file that directs the integrated graphics to the laptop display, and an external display straight from the external card
Also tried, without success :-/ I think is dead, or almost dead because I can still try to launch one X server on each graphics card then enable dragging between them via Xinerama, but it causes very poor performance (no 3D acceleration & co...)
Maybe I'll try with a ATI card, you never know... -
I accidentally added two .doc files by dragging and dropping into itunes, under my device, then the app tab, then file sharing for Adobe Reader, they show in iTunes file sharing window, but don't show on iPad 3, and I cannot delete them on iTunes screen? Please help!
First, I would advise you to apply Tao philosophy to this. Given the dysfunction of most software, if this was just an accidental copy and you don't want them on iPad and they are not showing up anyway, what's the problem? Forget it. It's not worth the hassles. I'm more concerned that you have psychological issues you need to be dealing with, not this. You are making much too unnecessary work and stress for yourself.
As for deleting them, I'm assuming you highlighted them and hit delete and it didn't work. If not, it should. Works for me. But if it doesn't, my advice is also not to worry about it, as annoying as the clutter is. It will eventually resolve itself (like when your data files corrupt or your iPad crashes, LOL. (I apologize for my cynicism but I am fed up with dysfunctional software). It's not worth the hassles of trying to figure out petty issues.
As for me, I have the opposite, and very serious problem. I've got Reader on my iPad too. But I can't move the pdfs out of it and onto my laptop with iTunes' dysfunctional file sharing. I get the error "file cannot be copied because you do not have permission to see its contents." I have hundreds of pdfs on my iPad that I converted from web surfing with other programs that also don't work and I can't get them off the iPad for backup and to have a synced library I can access from both laptop and iPad.
I called iTunes twice and both times they blamed it on the app, saying iTunes file sharing doesn't support third party apps and that I should call Adobe and talk them into writing the code that will work with iTunes. Yeah, right. And Reader is not the only problem. This is happening with iAnnotate and Write PDF and other apps.
I suspect that both of us have the root problem, perhaps Apple's greedy refusal to support the apps that it sells in the app store and are quasi-integrated enough to show up in the file sharing documents list, but can't be moved or deleted; and the apps that don't bother to make their apps fully work with iTunes file sharing.
If anyone has any solutions ...... -
Problem araised in adding two custom fields to ksb1 tcode.
hi experts,
I added tow fields vendor no, vendor name to Tcode:KSB1.
i used user-exit : coomep01 .
in this exit i added two fields to ci_rkpos (include table) . i.e zlifnr,zname1.
but that problem is ci_rkpos is not appearing in green color it means it is not transported .
in development client is working properly .
using sm34 i added fields names.
error is coming like this.
The following syntax error occurred in the program SAPLXKAEP :
"The data object "CS_RECORD" has no component called "ZLIFNR", but ther"
Error in ABAP application program.
The current ABAP program "SAPLKAEP" had to be terminated because one of the
here wat ever we add the zfields will appear in kaep_coac ,so in this structure two added fields are appeared in dev client
but,the same zfields when transported to quality is not appearing .
please suggest how to do??hi breakpoint.
yes i attached in transport.
in quality client.
wat ever i wriiten code in user exit it is coming ,but
incldue table structure is not coming ,and even that fields are appearing in v_tkalv ,but in structure kaep_coac
blank include strcuture CI_RKPOS is appearing ,but
in dev client is working properly, and in quality first of all report is going to dump.
here this tvode is using all 3 plants,how can i restrict to specified plant so that ,it will not affect others plant.
suggest me how to do??
Edited by: kamalsac on Aug 18, 2010 10:57 AM -
Linking two video clips together
I cannot find the way, how to link two video clips together so, that when moving one, the linked clip follows.
Is there a way of doing that?
The manual gives nothing with words: "linking video clips".
Message was edited by: TRSTYou can't link video clips to each other. You can nest them. Put the two clips in a sequence the way you want them. Put the sequence with the two clips inside your master sequence. They will act as a single clip. That's the only way.
-
Adding two leading zeroes infront of a variable(both character and numeric)
Hi Experts,
I have a variable v_data. Whatever is the value of the v_data, two leading zeroes should get added to it.
v_data may be numeric or charachter type.
I am using FM CONVERSION_EXIT_ALPHA_INPUT for adding two preceding zeroes for numeric types but for character types what logic I should use?
Currently I am doing:
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_data
IMPORTING
OUTPUT = v_data.
if v_data CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
SHIFT v_data BY 2 PLACES right.
v_data+0(1) = '0'.
v_data+0(2) = '0'.
endif.
But the above code is giving output like this: 0 P0001 but I want output like 00P0001.
How to fix it?
Regards,
Sangeeta.
Edited by: Sangeeta on Nov 11, 2008 6:22 AMCALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_data
IMPORTING
OUTPUT = v_data.
if v_data CA 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
SHIFT v_data BY 2 PLACES right.
v_data+0(1) = '0'.
v_data+1(1) = '0'. " change this
endif. -
I have added two new extension on CUCM, Directory not showing in attendant console even after resynch on CUCM and attendant cosnole
Any idea?Hello,
Can you tell us what versions of CUCM and CUxAC you are using? Just extensions alone in CUCM will not sync to the corporate directory within the attendant console application. You will at least have to have user's associated with those extensions and depending on your rule set within the console that should then bring those extensions into the console directory.
Thanks,
Tony
Maybe you are looking for
-
All Tracks Now Unknown Artist - Can I Reverse This And Restore All Artists
Got a new PC one year ago. Had 350 CD's and decided to go digital with iTunes. Bought two external USB drives. One to use one for backup. Was using iTunes very happily up to one week ago. External HD one crashed. Not a problem have an EXACT COPY that
-
I am trying to print an oversize document 950mm x 2300mm. With the printer set to "fit to printed area" and "oversized pages" and size "backdrop 950x2300" I get a print preview image in the printer window. When I click OK the save window appears.
-
Download multiple files with 1 HttpURLConnection
Hi, We have an application that downloads small text files (< 2 Kb) from a webserver. These files are downloaded 1 by 1 when needed. We open a HttpURLConnection, download 1 file and close the connection immediately afterwards. This is done for each f
-
How to delete iOS 8.1.2 if it has already been downloaded?
Believe it or not, my iPhone 5 still runs iOS 7.0.4. Recently it downloaded iOS 8.1.2. I suddently lost ~1GB of free space, then went to Settings and noticed it downloaded the update. I can't see iOS or anything similar under Storage. I want to delet
-
Hi Guru i was moved transfer rules BD1to BQ1 but bq1 side inactive , how to activate tranferrules Regards, siva