Question : Multiplying a double by -1

Ok I have my below code attached. Now I am sending data in where,

lat_direction is "S" and lon_direction is "W".

So the functions

  if (lat_direction == "S"){
                    
                    lat_val = (lat_val * -1);
              }

and

  if (lon_direction == "W")
              {
                    lon_val = (lon_val * -1);
              }


should make those double values negative right?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
package com.dcu.project.server;

import com.dcu.project.model.NMEAData;
import com.dcu.project.server.Tokenizer;

public class Manager {

	public NMEAData ParseData(String Data)
	{
		NMEAData gpsData = new NMEAData();
		Tokenizer tokenizer = new Tokenizer(Data);
		
	    String token = tokenizer.next();

	    while(token.endsWith("$GPRMC") == false){
	        token = tokenizer.next();
	    }
	    if (token.endsWith("$GPRMC")) {

	        // Time of fix
	        String theTime = tokenizer.next();
	        String Hour = theTime.substring(0, 2);
	        String Minutes = theTime.substring(2, 4);
	        String Seconds = theTime.substring(4, 6);
	        String newTime = (Hour+ ":" + Minutes +":" +Seconds+" UTC");

	        // Latitude
	        String Status = tokenizer.next();
	        String raw_lat = tokenizer.next();
	        String lat_deg = raw_lat.substring(0, 2);
	        String lat_min1 = raw_lat.substring(2, 4);
	        String lat_min2 = raw_lat.substring(5);
	        String lat_min3 = "0." + lat_min1 + lat_min2;
	        double lat_dec = Float.parseFloat(lat_min3)/.6f;
	        double lat_val = Float.parseFloat(lat_deg) + lat_dec;
	        

	        // Latitude direction
	        String lat_direction = tokenizer.next();
	        if (lat_direction == "S"){
	        	
	        	lat_val = (lat_val * -1);
	        }

	        // Longitude
	        String raw_lon = tokenizer.next();
	        String lon_deg = raw_lon.substring(0, 3);
	        String lon_min1 = raw_lon.substring(3, 5);
	        String lon_min2 = raw_lon.substring(6);      
	        String lon_min3 = "0." + lon_min1 + lon_min2;
	        double lon_dec = Float.parseFloat(lon_min3)/.6f;
	        double lon_val = Float.parseFloat(lon_deg) + lon_dec;
	    
	        
	        // Longitude direction
	        String lon_direction = tokenizer.next();
	        
	        if (lon_direction == "W")
	        {
	        	lon_val = (lon_val * -1);
	        }
	        
	        
	        //Speed
	        String speedknots = tokenizer.next();
	        double speed_knots = Float.parseFloat(speedknots);
	        double speedmpers = (speed_knots * 0.51);
	        
	        //Course
	        String course = tokenizer.next();
	        
	        //Date
	        String theDate = tokenizer.next();
	        String day = theDate.substring(0, 2);
	        String month = theDate.substring(2, 4);
	        String year = theDate.substring(4, 6);
	        String newDate = (day+"-"+month+"-"+year);
	        
	        gpsData.setTime(newTime);
	        gpsData.setDate(newDate);
	        gpsData.setLat(lat_val);
	        gpsData.setLongitude(lon_val);
	        gpsData.setSpeed(speedmpers);
	        gpsData.setCourse(course);
	        
	    }
		return gpsData;
	    
	    
	}
	
}

Answer : Multiplying a double by -1

Use
1:
2:
3:
if ("S".equals(lat_direction )) {
	latVal *= -1;
}
Random Solutions  
 
programming4us programming4us