运行limits例程,在bcc5.6下出错……

kingofark 2002-10-25 12:16:44
运行《C++标准程式库》p64 的limits1.cpp
在vc7下正常,在bcc5.6(bcb6)下出错。

//limits1.cpp
/* The following code example is taken from the book
* "The C++ Standard Library - A Tutorial and Reference"
* by Nicolai M. Josuttis, Addison-Wesley, 1999
*
* (C) Copyright Nicolai M. Josuttis 1999.
* Permission to copy, use, modify, sell and distribute this software
* is granted provided this copyright notice appears in all copies.
* This software is provided "as is" without express or implied
* warranty, and with no claim as to its suitability for any purpose.
*/
#include <iostream>
#include <limits>
#include <string>
using namespace std;

int main()
{
// use textual representation for bool
cout << boolalpha;

// print maximum of integral types
cout << "max(short): " << numeric_limits<short>::max() << endl;
cout << "max(int): " << numeric_limits<int>::max() << endl;
cout << "max(long): " << numeric_limits<long>::max() << endl;
cout << endl;

// print maximum of floating-point types
cout << "max(float): "
<< numeric_limits<float>::max() << endl;
cout << "max(double): "
<< numeric_limits<double>::max() << endl;
cout << "max(long double): "
<< numeric_limits<long double>::max() << endl; // 注意!这里出错!!
cout << endl;

// print whether char is signed
cout << "is_signed(char): "
<< numeric_limits<char>::is_signed << endl;
cout << endl;

// print whether numeric limits for type string exist
cout << "is_specialized(string): "
<< numeric_limits<string>::is_specialized << endl;
}
...全文
147 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liu_feng_fly 2002-10-25
  • 打赏
  • 举报
回复
报什么错啊?
kingofark 2002-10-25
  • 打赏
  • 举报
回复
《C++标准程式库》
p64的util/limits1.cpp范例运行情况:
WinXP/PIII733/256Mb 环境变量为vs.net和bcb6的缺省安装设置

VC7[o], BCB6[x]

BCB6运行到

cout << "max(long double): "
<< numeric_limits<long double>::max() << endl;

的时候,弹出讯息:

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOverflow with message 'Floating point overflow'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------


[VC7的场合]

在VC7中,numeric_limits<long double>::max()用 return LDBL_MAX;作返回,而在float.h中有

#define DBL_MAX 1.7976931348623158e+308 /* max value */
以及
#define LDBL_MAX DBL_MAX /* max value */


[bcb6的场合]

在BCB6中,numeric_limits<long double>::max()也用 return LDBL_MAX;作返回,而在float.h中有

#define LDBL_MAX std::_max_ldble
以及
extern long double _RTLENTRY _EXPDATA _max_ldble;

当然,不排除我自己机子设置等等意外情况。
fangrk 2002-10-25
  • 打赏
  • 举报
回复
我用Borland C++ Builder 5运行,没问题!

max(short): 32767
max(int): 2147483647
max(long): 2147483647

max(float): 3.40282e+38
max(double): 1.79769e+308
max(long double): 1.18973e+4932

is_signed(char): true

is_specialized(string): false

内容概要:本文系统介绍了基于核主成分分析(KPCA)的故障检测方法,重点实现了T²和Q统计指数的可视化,并提供了完整的Matlab代码实现与仿真分析流程。该方法通过核函数映射将原始非线性过程数据转换至高维特征空间,进行主成分提取与降维处理,进而构建T²和Q两种统计量用于监控系统运行状态,有效识别工业过程中的早期故障与异常行为。文中详细阐述了KPCA的数学原理、故障检测机制、控制限计算方法,并结合实际案例展示其在复杂非线性系统中的应用效果与优越性,具有较强的工程实用性。; 适合人群:具备一定信号处理、机器学习理论基础及Matlab编程能力的研究生、科研人员和工程技术人员,特别适用于从事工业过程监控、故障诊断、智能制造等相关领域的研究人员。; 使用场景及目标:①应用于化工、电力、制造等行业中关键设备的在线故障监测与早期预警;②作为学术研究中非线性降维与异常检测算法的对比基准;③帮助开发者掌握KPCA模型构建、参数调优及T²-Q统计图可视化等核心技术环节。; 阅读建议:建议读者结合所提供的Matlab代码进行动手实践,深入理解KPCA算法的核心步骤,重点关注核函数选择、主成分数确定及统计量阈值设定等关键参数的影响,以提升故障检测的灵敏度与准确性。

24,851

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧