Java Strictfp Keyword
Posted By : Surbhi Gupta | 31-Oct-2017
Introduction of Strictfp Keyword
1. Strictfp is a keyword in java utilized for limiting coasting point computations and guaranteeing same results on each stage while performing operations in the drifting point variable.
2.Floating point figurings are stage subordinate i.e. diverse output(floating-point esteems) is accomplished when a class document is keep running on various platforms(16/32/64 bit processors). To settle this sorts of issue, strictfp watchword was presented in JDK 1.2 form by following IEEE 754 measures for gliding point counts.
Important points:
1.strictfp modifier is used with classes, interfaces and methods only.
strictfp class Test
{
// all concrete methods here are
// implicitly strictfp.
}
strictfp interface Test
{
// all methods here becomes implicitly
// strictfp when used during inheritance.
}
class Car
{
// strictfp applied on a concrete method
strictfp void calculateSpeed(){}
}
2. At the point when a class or an interface is proclaimed with strictfp modifier, at that point all strategies announced in the class/interface, and all settled sorts pronounced in the class, are verifiably strictfp.
3. strictfp cannot be used with abstract methods. However, it can be used with abstract classes/interfaces.
4. Since methods of an interface are implicitly abstract, strictfp cannot be used with any method inside an interface.
strictfp interface Test
{
double sum();
strictfp double mul(); // compile-time error here
}
The strictfp keyword can be applied on methods, classes and interfaces.
strictfp class A{}//strictfp applied on class
strictfp interface M{}//strictfp applied on interface
class A{
strictfp void m(){}//strictfp applied on method
}
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Surbhi Gupta
Surbhi is a Java Developer and a simple ,straightforward, friendly person. She loves to work in a challenging job.