Home Java Docker
Home     Java

Java Topic

What is Java
History of Java
Freature of Java
Difference Between Java & C++
Java Environment Set Up
Java Hello World Program & its Internal Process
Java Hello World Program
JDK, JRE and JVM
Java Variables
Java Data Types & Unicode System
Java Operators
Java Keywords
Java Control Statements
Java if else
Java switch
Java for loop
Java While loop
Java Do While loop
Java break
Java continue
Java Oops Concept
Java Object & Class
Java Method
Java Constructor
Java Static Keyword
Java this Keyword
Java Inheritance
Java Hybrid Inheritance
Aggregation(HAS-A)
Java Polymorphism
Java method overloading
Java method overriding
Java Runtime polymorphism
Java Dynamic Binding
Super keyword
Final keyword
Difference Between method overloading and method overriding
Java Abstraction
Java Interface
Abstract class vs Interface
Java Encapsulation
Java Package
Java Access Modifiers
covariant return type
Instance initializer block
Java instanceof operator
Object Cloning in Java
Wrapper classes in Java
Java Strictfp Keyword
Recursion in Java
Java Command Line Arguments
Difference between object and class
Java String
Java String Class
Java Immutable String
Java Immutable Class
String Buffer
String Builder
String Buffer vs String
String Builder vs String Buffer
String Tokenizer in Java
Java Array
Java Exceptions Handling
Java Try-Catch block
Java Multiply Catch Block
Java Finally Block
Java Throws Keyword
Java Throw Keyword
Java Exception Propagation
Java Throw vs Throws
Final vs Finally vs Finalize
Exception Handling With Method Overridding
Java Multithreading
Lifecycle and States of a Thread in Java
How to create a thread in Java
Thread Scheduler in Java
Sleeping a thread in Java
Calling run() method
Joining a thread in Java
Naming a thread in Java
Thread Priority
Daemon Thread
Thread Pool
Thread Group
Shutdown hook
Multitasking vs Multithreading
Garbage Collection
RunTime Class
Java Synchronization
Synchronized block in Java
Static Synchronization in Java
Deadlock in Java
Inter Thread Communication in Java
Interrupting Thread in Java
Reentrant Monitor in Java
Java Applet
Animation in Applet
EventHandling in Applet
Display image in Applet
Displaying Graphics in Applet
Parameter in Applet
Java 8 Features
Java Lambda Expressions
Method References
Functional Interfaces
Java 8 Stream
Base64 Encode Decode
Default Method
for Each() Method
Collectors class
String Joiner Class
Optional Class
JavaScript Nashron
Parallel Array Sort
Type Interface
Parameter Reflection
Type and Repeating Annotations
JDBC Improvements

strictfp keyword in java

    A modifier called strictfp, which stands for strict floating-point, was added to Java version 1.2 as opposed to the base version. When executing operations on the floating-point variable, it is utilised in Java to restrict floating-point calculations and guarantee consistent outcomes across platforms.





    Floating-point calculations are platform-dependent, which means that different output (floating-point values) are obtained when a class file is run on different platforms (16/32/64 bit processors). To address this issue, the strictfp keyword was introduced in JDK 1.2 by adhering to IEEE 754 standards for floating-point calculations.






Why we use strictfp Keyword

  • When a class file is run on various systems (16/32/64 bit processors), different output (floating-point values) are obtained because floating-point calculations are platform-dependent. The strictfp keyword, which complies with IEEE 754 standards for floating-point calculations, was added in JDK 1.2 to fix this problem.
  • Abstract methods cannot be used with strictfp. It can, however, be used with abstract classes/interfaces.
  • Since all interface methods are implicitly abstract, strictfp cannot be applied to any interface method.
  • The strictfp keyword is no longer required in Java 17 because all floating point expressions are strictly evaluated.





strictfp Keyword usage with classes

strictfp class Main{
   
   // Here, every concrete method is implicitly strictfp. 
}


strictfp Keyword usage with Interfaces

strictfp interface Main{
   
   // Here, every method becomes implicit.
   // Using strictfp during inheritance    
}





strictfp Keyword usage with variables

strictfp interface Main{
    double add();  
    strictfp double divide();  // C.T Error
}


strictfp Keyword usage with method

class Main{  
 strictfp void Add(){      //strictfp applied on method  

 }
}  




Java example of strictfp keyword
 // Java example of strictfp keyword
class Main {
    public strictfp double add(){
        double a = 5e+05;
        double b = 3e+08;
        return a + b;
    }
    public static void main(String[] args){    
    	Main main = new Main();
        System.out.println(main.add());
    }
}



Output:

3.005E8 


Illegal use for strictfp keyword


The strictfp keyword cannot be used on constructors, variables, or abstract methods.


class Main{  
 strictfp abstract void  Add(){ }     //strictfp applied on method  
}  

class Main{  
 strictfp int   data=10;    //Modifier strictfp is not permitted here    
}  




class Main{  
 strictfp int  add(){}    //Modifier strictfp is not permitted here    
}  

Java Recursion Next »
« Perv Next »


Post your comment





Read Next Topic
Java Tutorial - Topic
covariant return type
Instance initializer block
Java instanceof operator
Object Cloning in Java
Wrapper classes in Java
Java Strictfp Keyword
Recursion in Java
Java Command Line Arguments
Difference between object and class
Read Other Java Chapter
Java Topic
Java Basic Tutorial
Java Control Statements
Java Classes & Object
Java Inheritance
Java Polymorphism
Java Abstraction
Java Encapsulation
Java OOPs Miscellaneous
Java Array
Java String
Java Exception Handling
Java Multithreading
Java Synchronization
Java Applet
Java 8 Features
Java 9 Features
Java Collection
Java Mcq
Java Interview Question
Tools
  

Useful Links

  • Home
  • Blog
  • About us
  • Contact Us
  • Privacy policy

Contact Us

Police Colony
Patna, Bihar
India

Email:

About DockerTpoint


India's largest site for Programming Tutorial as well as BANK, SSC, RAILWAY exam
and Campus placement preparation.