升星星了,庆祝一下,不过要先回答有关问题~ 详见内文


升星星了,庆祝一下,不过要先回答问题~~ 详见内文
在   希赛   改版前夕升至星星了(讨厌新版的样式),小小地庆祝一下。

为了给大家技术分,所以要先回答问题(是很简单的题目啦),回答对了才有分哦~~

我们都知道在计算机内部   int   和   float   都是采用   32   位二进制来表示的,它们在计算机内部表现形式是一致,也就是说一个   float   类型的数据根据内部的二进制位可以转换成   int   类型,反之亦是。当然了,long   和   double   也有这种关系的。

完成以下   float2int、int2float   两个方法来实现这种转换。

public   class   Test   {
  public   static   void   main(String[]   args)   {
    float   f   =   3.1415F;
    int   num   =   float2int(f);
    float   f1   =   int2float(num);    
    System.out.println(num);   //   输出   1078529622    
    System.out.println(f1);   //   输出   3.1415
  }

  public   static   int   float2int(float   f)   {
  
  }
  
  public   static   float   int2float(int   num)   {

  }
}

java J2EE 程序开发

age45 10 years, 5 months ago


:)

ryanzhu answered 10 years, 5 months ago


改版了确实很难看、

背着棺材漫步 answered 10 years, 5 months ago


恭喜一下,楼上的答案已经出来的,是不是晚了?我想应该不会吧.

level·5 answered 10 years, 5 months ago


宝宝?难道是个MM?

羽生霖rinn answered 10 years, 5 months ago


有点意思,JF

n1dhog answered 10 years, 5 months ago


走过路过~~~~~~~

jaymax answered 10 years, 5 months ago


static int float2int(float f){//1078529622
return Float.floatToIntBits(f);
}

西班牙大粽子 answered 10 years, 5 months ago


jf

himiko answered 10 years, 5 months ago


根据IEEE 754标准转的
自己写一个也是几分钟的事,繁简不是以代码多少做为标准的,你调用了别人写的一个函数一下搞定了就算简单了?

tsasd answered 10 years, 5 months ago


gx

你白兔爸爸 answered 10 years, 5 months ago


楼上二位说的对

夏天的十三岁 answered 10 years, 5 months ago


object的比较是通过
equals和hashCode,如果重写equals方法,那么hashCode方法也必须要重写,LZ可能要阐述这方面的东西吧。

硬不起来君 answered 10 years, 5 months ago


恭喜一下~
floatToIntBits
intBitsToFloat

最是一抹蘇打綠 answered 10 years, 5 months ago

Your Answer