Ir para conteúdo
  • Cadastre-se

Painel de líderes

Conteúdo popular

Showing content with the highest reputation on 01-04-2013 em todas as áreas

  1. Pessoal, A quem se interessar, seque abaixo função para realizar o arredondamento ABNT (Arredondamento utilizado no ECF) Escrevi na linguagem Harbour, mas, basta apenas trocar os comandos para converter para qualquer outra linguagem (Se precisarem de ajuda na conversão, é só postar aqui, que tentarei ajudar) FUNCTION Round_ABNT(nValor,nDecimais) LOCAL nRetorno:=nValor, cDecimais:=SubStr(Str(nValor),At('.',Str(nValor))+1), nSubsequente:=nDecimais+1 if nDecimais<1 RETURN Int(nRetorno) endif if Len(cDecimais) <= nDecimais RETURN nRetorno endif if SubStr(cDecimais,nSubsequente,1)>'5' .or. SubStr(cDecimais,nSubsequente,1)<'5' //Se a casa decimal SUBSEQUENTE for DIFERENTE de 5 nRetorno:=Round(nValor,nDecimais) //ARREDONDA elseif SubStr(cDecimais,nSubsequente,1)=='5' //Se a casa decimal SUBSEQUENTE for IGUAL a 5 if Mod(Val(SubStr(cDecimais,nDecimais,1)),2) <> 0 //Se a casa decimal que será CONSERVADA, for IMPAR nRetorno:=Round(nValor,nDecimais) //ARREDONDA else //se a casa decimal que será CONSERVADA, for PAR if Val(SubStr(cDecimais,nSubsequente+1,1)) > 0 //Se APÓS a casa decimal SUBSEQUENTE, houver ALGUM algarismo MAIOR que ZERO nRetorno:=Round(nValor,nDecimais) //ARREDONDA else //Se APÓS a casa decimal SUBSEQUENTE, não houver NENHUM outro algarismo ou TODOS forem iguais a ZERO nRetorno:=Truncate(nValor,nDecimais) //TRUNCA (Esse é o único momento em que o "arredondamento ABNT" se diferencia do "arredondamento normal") endif endif endif RETURN nRetorno FUNCTION Truncate(nValor,nDecimais) LOCAL nRetorno:=nValor, cDecimais:=SubStr(Str(nValor),At('.',Str(nValor))+1) if nDecimais<1 RETURN Int(nRetorno) endif if Len(cDecimais) <= nDecimais RETURN nRetorno endif nRetorno:=Val( Str(Int(nValor))+'.'+SubStr(cDecimais,1,nDecimais) ) RETURN nRetorno Nos vários testes que fiz aqui, funcionou muito bem, se encontrarem algum bug, favor, reportar aqui... Obrigado! Espero ter contribuído, Abraços, Reginaldo
    1 ponto
  2. boa tarde, estou tentando cancelar uma nota fiscal aqui no parana estou utilizando a versao do acbrnfe 0.7.7.1 capicom mais esta dando o erro que eu devo cancelar por evento
    1 ponto
  3. Atualizei o forum para versão 3.4.3 e outras aplicações como Downloads e blogs também tiveram updates... Mais informações sobre as correções na página da Invision: http://community.invisionpower.com/topic/380382-ipboard-343-and-application-maintenance-updates-released/ (humm.. dessa vez lembrei de rodar o arquivo de tradução para o Português novamente )
    1 ponto
  4. Para quem usa os componentes, o ACBrUtil tem essa função como
    1 ponto
  5. Essa função já existia em ACBrUtil.pas {----------------------------------------------------------------------------- Arredondamento segundo as normas da ABNT NBR 5891/77 (por: DSA) Fontes: http://www.sofazquemsabe.com/2011/01/como-fazer-arredondamento-da-numeracao.html http://partners.bematech.com.br/2011/12/edicao-98-entendendo-o-truncamento-e-arredondamento-no-ecf/ -----------------------------------------------------------------------------} function RoundABNT(const AValue: Double; const Digits: SmallInt):Double; var Pow, PowValue, RestPart : Extended; IntPart, FracPart, LastNumber : Integer; Begin Pow := intpower(10, abs(Digits) ); PowValue := SimpleRoundTo( AValue * Pow, -9) ; // SimpleRoundTo elimina dizimas ; IntPart := trunc( PowValue ); FracPart := trunc( frac( PowValue ) * 100); if (FracPart > 50) then Inc( IntPart ) else if (FracPart = 50) then begin LastNumber := round( frac( IntPart / 10) * 10); if odd(LastNumber) then Inc( IntPart ) else begin RestPart := frac( PowValue * 10 ) ; if RestPart > 0 then Inc( IntPart ); end ; end ; Result := (IntPart / Pow); end;
    1 ponto
×
×
  • Criar Novo...

Informação Importante

Colocamos cookies em seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies, caso contrário, assumiremos que você está bem para continuar.

The popup will be closed in 10 segundos...