91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 34KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-16
  • 語言: C/C++
  • 標簽:

資源簡介

本來開發(fā)計算器,發(fā)現(xiàn)要用到大數(shù)運算,于是寫了本代碼。包括大數(shù)的加減乘除,開方,包括浮點,符合處理。純C語言,在VS2010上測試OK,未知BUG若干。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?

/*
有符號的加減法可以轉化為無符號的加減法
小數(shù)可以用擴大10^n的整數(shù)表示
*/

/****************定義變量*********/

#define?THIS_MAXLEN?100??//數(shù)組長度?
#define?SHOW_MAXLEN?50??//自我調(diào)整中使用的最大長度?
#define?DIV_PREC???(THIS_MAXLEN-SHOW_MAXLEN)???//?除法精度相關,循環(huán)取商最大次數(shù)?,50?對應開方?17?的有效位

#define?RESULT_TYPE?signed?char
#define?RESULT_OK?0
#define?RESULT_ERR_MEM?1
#define?RESULT_ERR_DIVZERO?2
#define?RESULT_ERR_MINUS?3
#define?RESULT_ERR_OVERLEN?4


typedef?struct
{
????signed?char?len;//數(shù)據(jù)長度
????signed?char?*num;
}?bignumbase_st;

typedef?struct
{
??bignumbase_st?baseT;
??signed?char?symbol;//正負0正,1負
??signed?char?exponent;//指數(shù),10^e次方?
}?bignumESB_st;


/**********************************聲明函數(shù)**********************/
/*******聲明全局函數(shù)********/
//有符號大數(shù)加法
RESULT_TYPE?bigNumADD(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//有符號大數(shù)減法
RESULT_TYPE?bigNumSUB(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//有符號大數(shù)乘法
RESULT_TYPE?bigNumMUL(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//有符號大數(shù)除法
RESULT_TYPE?bigNumDIV(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//根號2
RESULT_TYPE?bigNumSQR(bignumESB_st?*const?pdstconst?bignumESB_st?*psrcconst?signed?char?effec);

/*********聲明內(nèi)部函數(shù)********/

//無符號大數(shù)加法
static?RESULT_TYPE?nsbigADD(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//無符號大數(shù)減法
static?RESULT_TYPE?nsbigSUB(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//無符號大數(shù)乘法
static?RESULT_TYPE?nsbigMUL(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//無符號大數(shù)除法?
static?RESULT_TYPE?nsbigDIV(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb);
//根號2
static?RESULT_TYPE?nsbigNumSQR(bignumESB_st?*const?pdstconst?bignumESB_st?*psrcconst?signed?char?effec);

//比較數(shù)組代表的無符號整數(shù)的大小,a>b=1a=b=0astatic?signed?char?arrcmp(const?bignumbase_st?*pa?const?bignumbase_st?*pb?);
//移動數(shù)組?改變長度?
static?void?bigNumTenfold(bignumbase_st?*const?pdstconst?bignumbase_st?*psrcconst?signed?char?exponent);
//去掉末尾的所有chart,返回去掉的數(shù)目?
static?signed?char?removeTailChart(signed?char?*pasigned?char?*plenconst?char?chart);
//去除開頭的所有的字符chart返回去掉的數(shù)目?
static?signed?char?removeHeadChart(signed?char?*pasigned?char?*plenconst?char?chart);
//調(diào)整結構體,不改變表示的值,使exponent盡量靠近0
static?void?bignumst_adjust(bignumESB_st?*const?pdstconst?unsigned?char?maxlen)?;
//設置結構體代數(shù)的有效位數(shù)
static?void?bignumst_valeffec(?bignumESB_st?*const?pdstconst?signed?char?effec)?;
/**************************************定義函數(shù)*******************************/

//有符號大數(shù)加法
RESULT_TYPE??bigNumADD(bignumESB_st?*const?pdstconst?bignumESB_st?*paconst?bignumESB_st?*pb)
{
????RESULT_TYPE?err;
????if(?pa->symbol?==?pb->symbol)
????{
??????????err=nsbigADD(?pdst?pa?pb);
????????pdst->symbol?=?pa->symbol?;
????}else
????{
????????if?(?pa->symbol?==0?)?//?正?

評論

共有 條評論