Link to home
Start Free TrialLog in
Avatar of Greystoke
Greystoke

asked on

Quick and (hopefully) simple float question

Hello all,

I've never tried to use a float in my JSP pages before, so hope I'm just doing something stupid - anyway, here is the code:

//**********************************************
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.lang.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<%
      float aTest = 90/60;
%>
<%= aTest %>
</body>
</html>
//**********************************************


The output I get on the screen is 1.0
How can I get it to show the correct 1.5?
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or just:    
float aTest = 90.0/60.0;
But that might give you warnings as you will be trying to fit a double into a float...

so:

float aTest = 90.0f / 60.0f ;

would probably be better ;-)