AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Zahlen zerlegen

Ein Thema von jensw_2000 · begonnen am 10. Okt 2013 · letzter Beitrag vom 11. Okt 2013
 
jensw_2000
(Gast)

n/a Beiträge
 
#1

Zahlen zerlegen

  Alt 10. Okt 2013, 22:50
Kann man unsigned Integer im Bereich von 0-999 effektiver (also mit weniger Code, Performance nicht sehr relevant) in Einer, Zehner und Hunderter zerlegen?

-----------
PS: optimierte Version
-----------

Delphi-Quellcode:

interface

type
  TZahlSplitter = class(TObject)
  public
    class function getEiner(aZahl: UInt): UInt;
    class function getZehner(aZahl: UInt): UInt;
    class function getHunderter(aZahl: UInt): UInt;
  end;

implementation

{ TZahlSplitter }

class function TZahlSplitter.getEiner(aZahl: UInt): UInt;
begin
  Result := aZahl mod 10;
end;

class function TZahlSplitter.getZehner(aZahl: UInt): UInt;
begin
  Result := (Zahl div 10) mod 10;
end;

class function TZahlSplitter.getHunderter(aZahl: UInt): UInt;
begin
  Result := (Zahl div 100) mod 10;
end;

Geändert von jensw_2000 (10. Okt 2013 um 23:15 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:07 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz