减值 [英] subtraction of values

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

问题描述

: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



如果您的值存储在文本文件中(例如"foo.txt"),则可能会执行以下操作:
If your values are stored inside a text file (e.g. ''foo.txt''), you may do somthing like:
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());
  }
}


如果您的意思是,例如说3172014307880002,0.001320664.将为6.192-0.001320664,这是3172014307880002之后的双精度值.您可以使用的一种存档方法是.

字符串绝对值;
字符串值="3172014307880002,0.001320664";
string []字符串= regex.split(value,,");
foreach(字符串中的字符串)
{
for(int i = 0; i< strings.length; i ++)
{
if(strings [i] .contain(."))
{
绝对=字符串[i];
double dabsolute = double.parse(absolute);
dabsolue-= 6.192;
标签lblTest = new label(); //创建一个新的标签控件(请为其分配ID)
lblTest.Text = dabsolute.Tostring();
}
}
}
希望这会有所帮助,如果您有任何不清楚的地方,请随时添加评论.
-------------------------------------------------- -
|公共静态void main(string [] args)|
| {|
| debug.writeline(希望这会有所帮助,如果有任何不清楚的地方,请随时添加注释.编程愉快"); |
|} |
-------------------------------------------------- -
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");|
|} |
---------------------------------------------------


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆