CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Java >  J2SE / 基础类

谁有Java源代码中floatToIntBits,intBitsToFloat的源代码?

楼主keikai(月影)2002-03-08 19:38:30 在 Java / J2SE / 基础类 提问

还有,doubleToLongBits  
  longBitsToDouble?  
  这些遵循IEEE754规范。  
  但是,我无法从Jb中找到他们的source   code  
  问题点数:50、回复次数:4Top

1 楼microflora(Li Yong)回复于 2002-03-08 19:47:34 得分 40

In   java   they   are   all   native   method  
  So   you   can't   find   source   code.  
  Because   native   methods   are   implemented   in   platform   depedent   way,  
  e.g.   *.dll   in   windowsTop

2 楼dope(吊儿郎当)回复于 2002-03-08 19:57:11 得分 10

/*  
    *   Find   the   bit   pattern   corresponding   to   a   given   float,   collapsing   NaNs  
    */  
  JNIEXPORT   jint   JNICALL  
  Java_java_lang_Float_floatToIntBits(JNIEnv   *env,   jclass   unused,   jfloat   v)  
  {  
          union   {  
  int   i;  
  float   f;  
          }   u;  
          if   (JVM_IsNaN((float)v))   {  
                  return   0x7fc00000;  
          }  
          u.f   =   (float)v;  
          return   (jint)u.i;  
  }  
   
  这是什么?Top

3 楼keikai(月影)回复于 2002-03-08 20:10:21 得分 0

应该讲第一位老兄说得是对的吧。  
  第二个,依我的经验看,这个并没有切实反映Java如何将float转换成为int   bits的。  
  在Java的帮助或者source   code里面这么注视的:  
   
  Returns   the   bit   represention   of   a   single-float   value.   The   result   is   a   representation   of   the   floating-point   argument   according   to   the   IEEE   754   floating-point   "single   precision"   bit   layout.   Bit   31   (the   bit   that   is   selected   by   the   mask   0x80000000)   represents   the   sign   of   the   floating-point   number.   Bits   30-23   (the   bits   that   are   selected   by   the   mask   0x7f800000)   represent   the   exponent.   Bits   22-0   (the   bits   that   are   selected   by   the   mask   0x007fffff)   represent   the   significand   (sometimes   called   the   mantissa)   of   the   floating-point   number.   If   the   argument   is   positive   infinity,   the   result   is   0x7f800000.   If   the   argument   is   negative   infinity,   the   result   is   0xff800000.   If   the   argument   is   NaN,   the   result   is   0x7fc00000.   In   all   cases,   the   result   is   an   integer   that,   when   given   to   the   intBitsToFloat(int)   method,   will   produce   a   floating-point   value   equal   to   the   argument   to   floatToIntBitsTop

4 楼dope(吊儿郎当)回复于 2002-03-08 22:59:41 得分 0

在src\share\classes\java\lang下float.java中,floatToIntBits为native方法,就是说实现与平台相关,应在c文件中。  
   
  在src\share\native\java\lang下float.c中的Java_java_lang_Float_floatToIntBits函数使用了union,输入为float,返回为int。  
   
  所以我认为这儿就是floatToIntBits的实现方法。Top

相关问题

  • java源代码??(48分)
  • 求JAVA编译器的源代码!
  • 保护java源代码的问题。
  • 哪里能找到java的源代码?
  • ********寻去java注释的源代码*********
  • 寻找<<java2图形设计卷2SWING>>一书源代码和<<java网络高级编程>>一书源代码
  • 关于<<thinking in java>>中的源代码执行的问题
  • 请问哪里可以下载thinking in java 中的源代码?
  • 求java写的mp3播放器(带源代码)
  • 谁有java的麻将的源代码?我需要。

关键词

  • source
  • floattointbits
  • x7
  • float
  • bits
  • argume
  • native
  • point
  • represent
  • lang

得分解答快速导航

  • 帖主:keikai
  • microflora
  • dope

相关链接

  • CSDN Java频道
  • Java类图书
  • Java类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo