本文介绍了减值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

: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
:3175064504780018,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

如何仅从逗号后的值中减去6.192值,即从浮点值中减去

: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

推荐答案

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



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());
  }
}



这篇关于减值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 21:46