Home Answers Viewqa Java-Beginners arithmetic operation on float number

 
 


shrikant dhobale
arithmetic operation on float number
1 Answer(s)      6 months and 16 days ago
Posted in : Java Beginners

hi here is my code

class divs { public static void main(String args[]) { double dub=14.2f,dou; int num; num=(int)dub; dou=dub-num; System.out.println(dou); } }

I convert Double Value DUB=14.2 into integer variable NUM . Now NUM Value is "14".When i make subtraction like(" dou=dub-num ") it will give output like "0.1999998092". but I want to show output like "0.20".why compiler give wrong output?

View Answers

December 6, 2012 at 10:53 AM


Floating-point numbers are imprecise, especially since they work in binary fractions (1/2, 1/4, 1/8, 1/16, 1/32, ...) instead of decimal fractions (1/10, 1/100, 1/1000, ...). Therefore it displays 0.1999998092 instead of 0.20.









Related Pages:
arithmetic operation on float number
arithmetic operation on float number  hi here is my code class divs { public static void main(String args[]) { double dub=14.2f,dou; int num; num=(int)dub; dou=dub-num
Arithmetic Operators
Arithmetic Operators Operator is used to perform operation on variable and values. Arithmetic Operators is used to perform arithmetic operations(like... the list of available arithmetic operators : OPERATOR WORK USE
The Arithmetic Operators
to calculate arithmetic operation. The java programming tutorial provide operators... Java Example Using Arithmetic Operators  ... the arithmetic values. First of all, we have to define class named "
string to float
string to float  hiii. how can i change my string value in float for some operation?? give me some code for this??   hello, if rate is your textfield then float FloPri = [rate.text floatValue]; the value
Java - Arithmetic Operation, Conversion and Casts in java
Java - Arithmetic Operation, Conversion and Casts in java..., this will be illegal operation. For storing your calculated int value in a byte.... This type of operation has illustrated below : In this example we will see
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java program which performs basic arithmetic operation addition,subtraction
PHP Float Number Format
PHP Float Number: In our daily life we use different kind of number systems. Integer and Float numbers are most common in use. In the current tutorial we will study about Float number system. Float number system or floating point
float validation for jTextField
float validation for jTextField  Hi; I try that users enter only float number into jtextfield but I can not handle it. I try regex in keylistener but I couldn't be successful. Can you help me please
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes  import java.io.*; interface arith { int a=5; int b=8; void add(); void mul(); void sub(); void
Arithmetic Testing for School Students
. This application allows the student to select the arithmetic operation... the student is asked to enter the answer for the arithmetic operation applied to the two...Arithmetic Testing for School Students In this section, we have created
The float Keyword
The float Keyword         The float is a Java keyword that may not be used as identifiers i.e.... single-precision floating-point number. It is also a java primitive data type
Conversion from int to float
Conversion from int to float: In this tutorial we will learn how to convert an int type value  to float type. Description: This program will take two...; to float type data. The line int a = Integer.parseInt(buffreader.readLine
Convert Integer to Float
into a float. The following programs helps you in converting an integer into a float type data.  Code Description: This program takes an integer number... Convert Integer to Float     
Convert Float to Integer
the is the '10.0F' is used for  representing the float type number. If the F can't... Convert Float to Integer       In this section, we will learn to convert a float type data
Write an event driven program to perform the arithmetic operations as shown in the interface
Write an event driven program to perform the arithmetic operations as shown... an event driven program to perform the arithmetic operations as shown... help me:   Here is an event driven example that will perform arithmetic
arithmetic expression tree
arithmetic expression tree  how to create the java code randomly for arithmetic expression tree
How to Store Float Value into Access Database - Java Beginners
How to Store Float Value into Access Database  Hello sir,I want to Store Student Marks Percentage into Access Database in Float Value how i can Store it.   Hi Friend, You can use double data type in place of float
MySQL Arithmetic
MySQL Arithmetic This example illustrates how to use arithmetic operator in the MySQL. In this example we use arithmetic operator (+, /, -, *, %).   Query   Output  
JSP Modulus
of number in jsp. Modulus is the remainder of division operation. Understand with Example In this section, you will learn how to determine the modulus of number in jsp. As you already know that modulus is the remainder of division operation. You
MySQL Arithmetic
MySQL Arithmetic       This example illustrates how to use arithmetic operator in the MySQL. Arithmetic operators are used to perform mathematical operations on two expressions
Arithmetic Operators in java 7
In this section you will learn about the Arithmetic operators. This is one type of operators
Java Biginteger
a number of methods for doing arithmetic with them... Java Biginteger       When working with arithmetic operations using int or long, if the value becomes
String Number Operations in JavaScript
operation on the string representation of the number that would not affect...; JavaScript in Number Operation The numbers is a central task for the many... String Number Operations in JavaScript  
Java reverse number
Java reverse number In this tutorial, you will learn how to reverse a number in java. In java, you can use arithmetic operators like division operator(/) and remainder operator(%) to reverse the number. The division operator returns
Arithmetic Operators
Arithmetic Operators       Arithmetic Operators are used to perform some mathematical... of arithmetic operators are given in a table: Symbol Name
Define float in Java
Define float in Java  Hi, What is the correct method to define float variables in Java? float f = 3.0f; double d = 3.0d; Thanks   Hi, Here is is an example of Float variable in Java. public class
why not float main?
why not float main?  why should the main be int or void?why cant it be float or char? why int main()?why not float main()?or char main
why not float main?
why not float main?  why should the main be int or void?why cant it be float or char? why int main()?why not float main()?or char main
NSString to float conversion
NSString to float conversion  HI, I my iPhone and iPad application I have to convert NSString to float. Provide me example of NSString to float conversion. Thanks   Hi, Please see NSString to float conversion
NSString to float conversion
NSString to float conversion  HI, I my iPhone and iPad application I have to convert NSString to float. Provide me example of NSString to float... = [NSScanner scannerWithString:@"20.10"]; float fXpos; [strXpos scanFloat:&
objective c define float
objective c define float  Hi, How to define float variable in objective c? Thanks   Hi, Here is the example of defining float variable. float i; i=10; Thanks   Hi, Here is another example: // File
php parse string to float
php parse string to float  Is there any Regex or way to get float from a string
div style float right
div style float right  How to align div to right? Share me the code for div style float right. Thanks   Hi, You can use following code: <div style="float: right; widht:300px; height:600px;"> <p>Content<
Transfer the content of a float array into float buffer.
Transfer the content of a float array into float buffer.  In this tutorial, we will see how to transfer the content of a float array into float buffer...; The allocate(..)method allocate a new float buffer.  
Mysql Date Arithmetic
Mysql Date Arithmetic       Date Arithmetic is used to display the current date, interval in current... 'Date Arithmetic' in Mysql. To grasp this example, we  run the select now
search operation - Java Beginners
search operation  how to retrive all the similar elements (search operation ) on xml document using regular expressions
Transfer the content of a float buffer into float array.
Transfer the content of a float buffer into float array.  In this tutorial, we will see how to transfer the content of a float buffer into float array...; The allocate(..)method allocate a new float buffer.  
Compare a float buffer with another float buffer.
Compare a float buffer with another float buffer.  In this tutorial, we will see how to compare a float buffer with another float buffer. FloatBuffer...(..)method allocate a new float buffer. int compareTo
Insert Operation Error - WebSevices
Insert Operation Error  Hai, How i store my full resume in database[Mysql] using PHP. Any one Know the code..... Help me
Number Format Exception
.  A Number Format Exception occurs in the java code when a programmer tries to convert a String into a number. The Number might be int,float or any java... Number Format Exception     
J2ME Random Number
J2ME Random Number       In this application we are going to generate the random number using Random... nextFloat returns the next pseudorandom, uniformly distributed float value from
login/logout operation
login/logout operation  how to do log in/out operations in jsp plz kindly send the steps leing behind this operation  
PHP Arithmetic Operator
Arithmetic Operators: These are the most basic kind of operators. The PHP Arithmetic operator is used to perform addition(+), subtraction(-), Division(/), Multiplication(*), modulus(%). with variable or value. We all have done in our
Java code for buffer operation...!!!
Java code for buffer operation...!!!  Implement a buffer operation using character array, storing last 100 characters inserted by user. Make method to get and retrieve???   The given code accepts the characters from
login/logout operation
login/logout operation  how to do log in/out operations in jsp plz kindly send the steps leing behind this operation  
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular
Searching operation in JAva
Searching operation in JAva  Sir, I have made a project for the Dispatch section of my office. I have to search for letters that are dispatched on a particular date. Now there are thousands of letters dispatched on a particular