免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2012年9月26日 星期三

C 與 PI

PI , π, 3.141592..., 
山巔一寺一壺酒, 爾... 

在C語言裡 如何得到 PI的值? 
如果是用微軟的Visaul Studio (VC) 

  • #include <math.h>
  • 在compiler 的preproecessor 定義中加入  _USE_MATH_DEFINES

//=== adhoc approaches
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif


const double pi = 22.0 / 7 ;  (不夠準)
const double pi = 355.0 / 113;  (比22/7 好些)
const double pi = acos(-1);
const double pi = 4.0 * atan(1.0);


3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491...

//=== linux
grep -i pi /usr/include/math.h 

# define M_PI 3.14159265358979323846 /* pi */
# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
# define M_PIl 3.1415926535897932384626433832795029L  /* pi */


//=== 精準度(有效位數?)
#include <stdio.h>
#include <float.h>
double 的精準度 DBL_DIG
float 的精準度 FLT_DIG

long double ?



[ref] 




2012年9月11日 星期二

FlashDevelop debug needs jre/bin and msvcr71.dll

//=== 安裝,  http://www.flashdevelop.org/wikidocs/index.php?title=Installation

預備動作
0. 32bit Java JRE1.6  , 必要!
1. Flash Player debug 版, Flash ActiveX Control debug 版 
   http://www.adobe.com/support/flashplayer/downloads.html

2. TortoiseSVN

[note]  
* FD (FlashDevelop)的可攜性頗佳, 其實裝完 FD (FlashDevelop) 之後
再裝以上三者也可以,   不過事後要設定路徑較麻煩 ...

**  必須將 jre/bin 加到使用者的環境 Path 中, FD 才能正常啟動除錯功能


//=== 組態設定,    http://www.flashdevelop.org/wikidocs/index.php?title=Configuration

相關組態檔案存放位置
Win XP:  C:\Document and Settings\<username>\Local Settings\Application Data\FlashDevelop
Win 7/Win8: C:\Users\<username>\AppData\Local\FlashDevelop

per-user 的組態目錄 可以殺掉沒關係 FD重開時會再自動產生 不過客製的(customized) 修改
就不見了


//=== FAQ , http://www.flashdevelop.org/wikidocs/index.php?title=F.A.Q
[Q]  FlashDevelop 能否在  64-bit Windows 執行?

[A] 是的,  但需要32bit Java JRE.



[Q]  cannot load  jvm.dll?
[try]
32bit-os:
copy JRE_BIN\msvcr71.dll to Windows\System32

64bit-os:
copy JRE_BIN\msvcr71.dll to Windows\SysWOW64

[ref] http://www.flashdevelop.org/community/viewtopic.php?f=6&t=8374


//=== Source Code, http://code.google.com/p/flashdevelop/

Compile/Build
* .NET 2.0 framework
*  Visual Studio 2008 or C# Express 2008 
*  "x86" target (Scintilla DLL isn't 64bit compatible)
*  build PluginCore project first, then build solution.