++ increment of float inacurate with no compiles warnings???
Hi,
I have a simple class that uses the ++ opperator to increment a floting point variable. However the result is not correct and there are no compiler warnings about loss of precision. The class is....
class Test
public static void main(String[] args)
float x = 1.123f;
x++;
System.out.println(x);
}However the result of X is 2.1230001. X will now fail any if statements such as
if (x = 2.123)
// Do Something
}So my question is
1) Why does this happen
2) Is it possible to use the ++ operator on a floating point variable with accuracy?
I'm studying for the SCJP and attention to details like this is everything!!
Thanks!
Alan K.
It has nothing to do with ++.
SOME THINGS YOU SHOULD KNOW ABOUT FLOATING-POINT ARITHMETIC
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Another good (slightly simpler) FP explanation:
http://mindprod.com/jgloss/floatingpoint.html
Similar Messages
-
Impdp with created with compilation warnings
expdp without any error but impdp.
ORA-39082: Object type TRIGGER:"myuser_name"."AA_CUR_TRIGGER" created with compilation warnings.
I pick one of compilation errors as above. There are many other errors such as view.
Did I miss anything? Please help.The problem could just be ordering or information missing. expdp exports object in the best order it can think of. By this I mean, if you are exporting a table, it will export the table before the index, and the index before the index_statistics, etc. Sometimes there are objects that are dependent on other objects that are not yet imported. Let's say that you have a procedure that uses a view and a view that uses a procedure. The way expdp/impdp works (and I'm not sure of the order of these 2 objects) is that it will create all procedures and then later on, create all views. (or the other way around, all views, then all procedures). In the case I described above, if views are created before procedures, then the view that calls a procedure will get a compilation warning because the procedure has not been imported yet. If it is the other way around, then the procedure will get the compilation warning because the view is not there.
The objects will be created and they will recompile the next time you use them. You could also go in after the impdp job is complete and just issue the
alter object_type schema.name compile;
and they should compile.
The other problem you could be running into is if the object you are creating uses another object that is not in the database or if the grant is not there. Let's say that you create a procedure proc_a and it is in the user1 schema. If you try to create a view in user2 that calls proc_a, and if proc_a does not exist, you can get the compilation warning.
So, I don't think you missed anything.
Hope this helps.
Dean -
SQL developer not showing compiler warnings
I'm just testing out the new compiler warning contained in 11g related to the "when others" exception handler when it does not have a subsequent raise or raise_application_error.
in SQL plus, this works fine:
SQL> alter session set plsql_warnings='enable:all';
Session altered.
SQL>
SQL> create or replace function do_stuff
2 return number
3 as
4 v_return number;
5 begin
6
7 v_return := 3;
8 return v_return;
9
10 exception
11 when others then
12 return null;
13 end;
14 /
SP2-0806: Function created with compilation warnings
SQL> show errors;
Errors for FUNCTION DO_STUFF:
LINE/COL ERROR
1/1 PLW-05018: unit DO_STUFF omitted optional AUTHID clause; default
value DEFINER used
11/6 PLW-06009: procedure "DO_STUFF" OTHERS handler does not end in
RAISE or RAISE_APPLICATION_ERRORbut in SQL developer the output is:
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
session SET altered.
FUNCTION do_stuff compiled
No Errors.Anyone experience this issue? is there some setting that makes SQL developer behave differently?it must be something I'm doing wrong, above, I was running under windows 7 pointing at the version above.
I just tried it under an Enterprise Linux pointing at
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production and I get exactly the same script output and no compiler window....
actually...... if I go into a procedure window from the schema browser and compile it there, then I get the correct warning messages..... the problem is I mostly develop from .sql files extracted from source control rather than directly from the schema browser, I just want the sql worksheet to be able to show me the same compiler log window..... -
SDK CVI compiler Warnings 64-bit
It seems I am finding CVI Compiler warnings when compiling 64 Bit applications with SDK. I don't get these warning errors when I compile the same applications for 32 Bit.
For example the CVI Compiler warning that I just found was found when I used SDK header file: "SetupAPI.h" with the typedef struct: SP_DEVINFO_DATA and SP_DEVICE_INTERFACE_DATA.
The warning message I got was when I compiled the statements with the SetupAPI.h file included:
SP_DEVINFO_DATA DeviceInfoData;
/* warning message */
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
// Warning: Conversion from 'unsigned __int64' to 'DWORD' might lose data.
/*warning message*/
SP_DEVICE_INTERFACE_DATA did = {sizeof(did)};
// Warning: Conversion from 'unsigned __int64' to 'DWORD' might lose data.
When I compile these statements in 32-Bit I don't get these errors.
Of course I can change the "SetupAPI.H" SDK Header supplied by NI but that defeats the whole purpose of why NI would distribute the header file in the first place.OK - Milan -
I think you misunderstood what I was writing about.
If you look at the SetupAPI.h file that is supplied by NI SDK with CVI 2010 at line 700 with the following typedef struct:
// Device information structure (references a device instance
// that is a member of a device information set)
typedef struct _SP_DEVINFO_DATA {
DWORD cbSize;
GUID ClassGuid;
DWORD DevInst; // DEVINST handle
ULONG_PTR Reserved;
} SP_DEVINFO_DATA, *PSP_DEVINFO_DATA;
The DWORD is defined as
"typedef unsigned long"
in cvidef.h (CVI 2010) header file.
Yes I could change the SetupAPI.h inside the header file to change the type to be __int64 instead so that it works with 64 Bit. However, if other applications that are written for 32 bit will now be impacted if the SetupAPI.h is used with the __int64 data type DWORD.
So what NI should so everywhere where they define "DWORD" that is used in the SDK they should have a conditional compile to set the type to "typedef __int64" in CVI 64-bit applications and
"typedef unsigned long" in 32 Bit Applications. -
While transferring several files to the G-Raid, the G-Raid device locks up with the following warnings: "The Finder can't complete the operation because some data in (whatever file) can't be read or written (Error code - 36).” NOt sure this is a G-Raid problem, can anyone help?
This is likely a problem with the drive itself. This error indicates unspecified I/O errors with the drive, which can be from a hardware fault, or a formatting issue. If the drive has valuable data on it, then try connecting it to another PC to get the data off, and then try fully partitioning and formatting the drive with Disk Utility. If this corrects the error then you should be able to use the drive again as it was likely a formatting issue, but if the problem continues then it is likely a hardware fault and the best solution is to be safe and replace the drive.
-
Data not visible in table o/p when compiled with webdynpro compiler
Hi,
I am using a Z BAPI to retrieve data from backend ECC6 server and show it using a VC application.
When I compile this VC application using FLASH(FLEX2), the data is shown in the table, whilst if the VC application is compiled using Webdynpro compiler, the data is not shown in the table.
The No. Of Rows parameter has been updated with 10.
Please suggest what can be done so that data is shown when compiled with Webdynpro compiler.
Regards,
RanuHi Ranu,
WebDynpro Compiler only supports Webservices.
You can look at the below link to get into full details -
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/limitationsofWeb+Dynpro
Regards,
Vipin Vijayan. -
Floating Fields with Designer ES2
I just did an upgrade to Designer ES2.
I created a new form with static textfields and floating textfields
then i created a button that filles the floating field with a text using javascript.
xfa.resolveNode("form1.#subform[0].Textfield1").rawValue
= "it doen't work";
But it doesn't work
When i make the floating field visible, so i see the normally hidden field, the i see that the script works, but that te tekst doesn't show in my static textfield
Anyone else with this problem?
Can anyone tell me what i'm doing wrong?
In the previous Designer ES it worked fine and opening those forms in ES2 still work
But creating a new form with a floating text doesn't workI reinstalled Both Designer 8.x and ES2 several times, but i have the same problem with both versions.
Now i only have Designer 8.x installed on my WinXP.
i created a new empty form and add a static text field and a button.
within that static textfield i insert a floating field.
i add a Formcalc script to the click function of the button: Field.rawValue = "hello"
i save it as a dynamic form.
preview the form and when i click the button nothing happens
Then i change the presence of the floating field to visible, so a normally hidden field is visible
Now without changing anything i preview the document en click on the button
Now i see the text in the field i just made visible, but still not in the static textfield where i inserted that floating field. -
For what are "CREATE SEQUENCE ... INCREMENT BY 1 START WITH 1" ?
I have seen SQL statements for Oracle Databases in the form like
CREATE SEQUENCE sq_ordernum INCREMENT BY 1 START WITH 1
For what are these kind of statements and how can I access/use them?
Petersequence is used to increment a number when ever you use seq.next val;
SQL> CREATE SEQUENCE sq_ordernum INCREMENT BY 1 START WITH 1
2 /
Sequence created.
SQL> select sq_ordernum.nextval from dual;
NEXTVAL
1
SQL> select sq_ordernum.nextval from dual;
NEXTVAL
2
SQL> select sq_ordernum.nextval from dual;
NEXTVAL
3
SQL> select sq_ordernum.nextval from dual;
NEXTVAL
4
SQL> select sq_ordernum.nextval from dual;
NEXTVAL
5
SQL> select sq_ordernum.currval from dual;
CURRVAL
5
SQL> -
Folks !
I have been getting this nuisance warning for ages and I though it was time to get rid of them. Compiling any JSP in JDeveloper I get:
Warning: package name _jsp.xxxx does not match source file name xxxx
What is it ?
Also, anyway to suppress Java compiler warnings so I can look at errors only ?
thanks a lot,
-SanjayI have the same problem (many warnings....), but it hasn't cause any problem while running.
I thing this is becasuse I use uppercase letters inside names of directories.
Example:
- my page: public_html/BP/Aplikace.jsp
- compiled to .java: classes\.jsps\_BP\_Aplikace.java
- third line of Aplikace.java: package bp;
So there is the problem: "_BP" (name of directory) versus "_bp" (name of package)!!!
I thing this is a bug.
If I am right, I have question for JDevTeam - will it be fixed? -
Can I compiler servlet with java compiler?
Can I compiler servlet with java compiler?
Here is an example of it:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloWorldServlet extends HttpServlet
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException , IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
StringBuffer sb = new StringBuffer();
sb.append("<html><body><h1>");
sb.append("Hello World");
sb.append("</h1></body></html>");
out.print(sb.toString());
out.close();
}Can I compiler servlet with java compiler?
yes.
just include the correct jarfiles in your classpath. -
TSQL code that causes table data to be deleted rather than fail with a compilation error
Afternoon,
I recently did this by accident and it felt as though it should have failed with a compilation error rather than run
A query of the form
delete from jobs
where id in
select id from calibrations
will delete all rows in the jobs table when the id column exists in the jobs table, but not the calibrations table. This should fail with a compilation error.
the following sql can be used to generate a test database to show the problem
USE [test]
GO
/****** Object: Table [dbo].[calibrations] Script Date: 28/11/2014 13:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[calibrations](
[JobId] [int] NULL,
[textfield] [nvarchar](50) NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[jobs] Script Date: 28/11/2014 13:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[jobs](
[Id] [int] NOT NULL,
[Name] [nchar](10) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[calibrations] ([JobId], [textfield]) VALUES (1, N'something')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (1, N'a ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (2, N'b ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (3, N'c ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (4, N'd ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (5, N'e ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (6, N'f ')
GO
Simon
simonwill delete all rows in the jobs table when the id column exists in the jobs table,
but not the calibrations table. This should fail with a compilation error.
Hello Simon,
That's a bug in your T-SQL Statement, not in SQL Server. The Statement as it is valid and column "id" exists, so why should it fail on compilation?
And that is the reason why we always should use full qualified object name, e.g. like
delete from jobs AS J
where J.id in
select SUB.id from calibrations AS SUB
and this Statement should fail on compilation.
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Flex SDK compiler warnings localization
Hi, guys.
Wonder if i can disable localization of compiler warnings, so that sdk compiler won't take system locale (windows) and use english instead?
Thanx in advance,
Tim Tekaevuse in compiler option : -locale en_US
-
Problem with a compiled program
Hello,
I have a problem with a compiled program on labview 6i.
This program used a serial port (COM1 or COM2).
During the launching of the ".exe ", a fatal error occurs.
Here this error:
=> APPLICATION caused an invalid page fault in
=> module LVRT.DLL at 0167:30164426.
Can somebody help me?
Regards
CedricCedric,
This problem was fixed in the LabVIEW 6.0.2 update. You can download this update (along with the updated runtime engine) from our website.
Good luck with your application, and have a pleasant day.
Sincerely,
Darren N.
NI Applications Engineer
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman -
Generics, factory methods and compiler warnings
Hi all,
I have a parametrized class where new objects are created via a factory. The problem is that I'm getting some compiler warnings. Am I missing something or there's no way to avoid them?
public interface Schedulable {
// methods here
public class Scheduler<T extends Schedulable> {
// should this be parameterized? If yes, how?
// (it's not possible to use T while <? extends Schedulable> gives problems)
private static Scheduler scheduler;
private NodeManager nodes;
private DefaultServiceManager<T> services;
private Timer timer;
private LifecycleManager lifecycle;
public static synchronized <E extends Schedulable> QueueScheduler<E> newInstance() {
if (scheduler == null) {
scheduler = new Scheduler();
scheduler.nodes = DefaultNodeManager.newInstance(scheduler);
scheduler.services = new DefaultServiceManager<E>(scheduler.nodes);
scheduler.timer = new Timer(scheduler);
scheduler.lifecycle = new LifecycleManager(scheduler,
scheduler.timer);
// these fields are initialized here and not into the constructor in order to avoid
// the 'this' reference to escape (see //http://www-128.ibm.com/developerworks/java/library/j-jtp07265/index.html
// for example)
// all the fields initialized above generate a warning
return scheduler;
protected Scheduler() {
// initialization of some fields here
// methods here
// methods here
}Thanks,
MicheleOops, sorry, didn't see the variable actually is a static, raw one. Here you will have a problem, as for once you cannot use the E for the static variable and second you could not guarantee that a previously created Scheduler would have the same type parameter as the one you are going to create:FirstSchedulable a = Scheduler.newInstance();
SecondSchedulable b = Scheduler.newInstance(); // would fail!The second call would fail, as the first would have created an instance of Scheduler<FirstSchedulable>, which is stored in the static variable scheduler and not compatible to a Scheduler<SecondSchedulable>.
You should rethink you design. -
Hi ,
Downloaded Sunstudio 12.2. Installed . I want find out if C++ compiler 5.11 is compatible with C++ compiler 5.8.
Using 5.11 compiler, can I link to 5.8-compiled sahred libs?
Edited by: 849112 on Mar 31, 2011 9:39 PM
Edited by: 849112 on Mar 31, 2011 9:39 PMBinaries created by Studio 5.x compilers are forward compatible. If you build a binary (object file or library) with an older compiler, you can link it into a program built with a newer compiler. The reverse will not always work. That is, newer compilers maintain interfaces used by older compilers, but might code generated by newer compilers can depend on interfaces not available with older compilers.
The compatibility story is described in more detail at the bottom of the Component Matrix page;
http://www.oracle.com/technetwork/server-storage/solarisstudio/training/index-jsp-141991.html
Maybe you are looking for
-
Please forward this to corporate... I pay for 5 phones a month, currently at 250 + a month, putting it into perspective... a car payment. I've been a customer since 2000 both with my exhusband and after my divorce, I've paid for them. I was on the
-
I have Windows XP and PSE6. I just bought Elements + (it's the PSE6 Windows version), downloaded it, and went through the automatic install. Now my editor crashes every time I open it. Tried restarting to no avail. What happened?
-
Question POS point to point with no APS
One side POS1/0/0 SECTION LOF = 0 LOS = 0 BIP(B1) = 0 LINE AIS = 0 RDI = 0 FEBE = 0 BIP(B2) = 0 PATH AIS = 1 RDI = 2 FEBE = 1119 BIP(B3) = 463 PLM = 4 UNEQ = 0 TIM = 0 TIU = 0 LOP = 0 NEWPTR = 0 PSE = 0 NSE = 0 Active Defects: None Active Alarms: Non
-
Inside a movie clip on the stage i have 15 more movie clips, called box1 - box 15. inside each box instance is a text field called date. i want to fill in the text field in box1 with the current date, and box2 with tomorrow's, and so on. How can i as
-
hi i'm creating a calculator program and i want to integrate my pythagorean therum program in but i don't want to put all the source in is there anyway i can just link the file in thanks