Click here to Skip to main content
15,890,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
:7310064507600005,0.42063698
:3171035811460001,0.2707711
:7371094611760009,0.25769743
:3172053105550001,0.16933058
:3173055210640002,0.16111518
:3172041501510005,0.095413744
:1171044806680001,0.047679488
:3325074505640001,0.045816887
:3372020201330001,0.015330133
:3171060609620003,0.013726625
:3173045608570001,0.0084843775
:1904044706870003,0.0059423423
:3328146202710001,0.0042611356
:3174080406420002,0
:7501020107930013,0
:3171076711630001,0
:1371045603460002,0.24441583
:7371131007680006,0.14325395
:1903015307680001,0.09625417
:3576015801920001,0.047576003
:1304104505770002,0.023352606
:3175064504780019,0.013456003
:3173014606860008,0.008172007
:3402145508880002,0.0069786487
:3175034202580005,0.0017725254
:3172014307880002,0.001320664
:3327056501890002,0
:1671051804860006,0
:3175081804770006,0
:3325022905910002,0
:3328104310780005,0
:3371024706790003,0

how to subtract 6.192 value, from only values after comma(,) ie from float values
Posted

Java
float value = // insert value here
value -= 6.192

How else would you expect it to be done?
 
Share this answer
 
If your values are stored inside a text file (e.g. 'foo.txt'), you may do somthing like:
Java
try
{
  FileInputStream fstream = new FileInputStream("foo.txt");
  DataInputStream in = new DataInputStream(fstream);
  BufferedReader br = new BufferedReader(new InputStreamReader(in));
  String strLine;
  while ((strLine = br.readLine()) != null)
  {
    String [] sp = strLine.split(",");
    if (sp.length == 2)
    {
      System.out.println (Double.parseDouble(sp[1])-6.192 );
    }
  }
  in.close();
  }
  catch (Exception e)
  {
    System.err.println("Error: " + e.getMessage());
  }
}
 
Share this answer
 
v3
Comments
udayz999 19-Oct-11 1:50am    
Thank u pallini its working
udayz999 19-Oct-11 5:13am    
i hav a log value 1573950 log1573950 how to subtract these value from before given float values by using math.util class
CPallini 19-Oct-11 15:32pm    
Could you please elaborate?
if what u mean is lets say for example 3172014307880002,0.001320664. will be 6.192 - 0.001320664 which is the double value after 3172014307880002. one of the ways you can archive this is.

string absolute;
string value = "3172014307880002,0.001320664";
string[] stringss = regex.split(value, ",");
foreach(string strings in stringss)
{
for(int i = 0; i < strings.length; i++)
{
if(strings[i].contain("."))
{
absolute = strings[i];
double dabsolute = double.parse(absolute);
dabsolue -= 6.192;
Label lblTest = new label(); //create a new label control (Please assign ID to it)
lblTest.Text = dabsolute.Tostring();
}
}
}
Hope this will help, if there is anything not clear to you feel free add a comment.
---------------------------------------------------
|Public static void main(string[] args) |
|{ |
| debug.writeline("Hope this will help, if there is anything not clear to you feel free to add a comment.Happy Programming");|
|} |
---------------------------------------------------
 
Share this answer
 
v2
Comments
Richard MacCutchan 18-Oct-11 9:07am    
Please use <pre/> tags around your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900