| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
虽然我知道浮点运算有误差,但是编译期和执行期出来的数不一样还是有点淡腾
#include <stdio.h>
#include <math.h>
const int MAX = 10001;
int main()
{
int b = 25;
printf("%d\n", b);
printf("%d\t%s\n", (int)pow(sqrt((double)b), 2), int(pow(sqrt((double)b), 2)) == b ? "Y" : "N");
printf("%d\t%s\n", (int)pow(sqrt((double)25), 2), int(pow(sqrt((double)25), 2)) == 25 ? "Y" : "N");
}
25
24 N
25 Y
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --en
able-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=ming
w32 --prefix=/mingw
Thread model: win32
gcc version 4.7.2 (GCC)
vc11倒是正常
25
25 Y
25 Y
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.51106.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator