Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 670991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:19:28+00:00 2026-05-14T00:19:28+00:00

The difference between Chr and Char when used in converting types is that one

  • 0

The difference between Chr and Char when used in converting types is that one is a function and the other is cast

So: Char(66) = Chr(66)

I don’t think there is any performance difference (at least I’ve never noticed any, one probably calls the other)…. I’m fairly sure someone will correct me on this!

EDIT Thanks to Ulrich for the test proving they are in fact identical.
EDIT 2 Can anyone think of a case where they might not be identical, e.g. you are pushed towards using one over the other due to the context?

Which do you use in your code and why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:19:29+00:00Added an answer on May 14, 2026 at 12:19 am

    I did a small test in D2007:

    program CharChr;
    
    {$APPTYPE CONSOLE}
    
    uses
      Windows;
    
    function GetSomeByte: Byte;
    begin
      Result := Random(26) + 65;
    end;
    
    procedure DoTests;
    var
      b: Byte;
      c: Char;
    begin
      b := GetSomeByte;
      IsCharAlpha(Chr(b));
      b := GetSomeByte;
      IsCharAlpha(Char(b));
    
      b := GetSomeByte;
      c := Chr(b);
      b := GetSomeByte;
      c := Char(b);
    end;
    
    begin
      Randomize;
      DoTests;
    end.
    

    Both calls produce the same assembly code:

    CharChr.dpr.19: IsCharAlpha(Chr(b));
    00403AE0 8A45FF           mov al,[ebp-$01]
    00403AE3 50               push eax
    00403AE4 E86FFFFFFF       call IsCharAlpha
    CharChr.dpr.21: IsCharAlpha(Char(b));
    00403AF1 8A45FF           mov al,[ebp-$01]
    00403AF4 50               push eax
    00403AF5 E85EFFFFFF       call IsCharAlpha
    
    CharChr.dpr.24: c := Chr(b);
    00403B02 8A45FF           mov al,[ebp-$01]
    00403B05 8845FE           mov [ebp-$02],al
    CharChr.dpr.26: c := Char(b);
    00403B10 8A45FF           mov al,[ebp-$01]
    00403B13 8845FE           mov [ebp-$02],al
    

    Edit: Modified sample to mitigate Nick’s concerns.

    Edit 2: Nick’s wish is my command. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 370k
  • Answers 370k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I have this same issue and it would be very… May 14, 2026 at 6:36 pm
  • Editorial Team
    Editorial Team added an answer what use are 'standalone parentheses'? For all intents and purposes,… May 14, 2026 at 6:36 pm
  • Editorial Team
    Editorial Team added an answer My comments: either approach for the key is fine. I… May 14, 2026 at 6:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.