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

  • Home
  • SEARCH
  • 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 571857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:33:06+00:00 2026-05-13T13:33:06+00:00

I am having trouble in Tcl using numbers with leading zeros. I am parsing

  • 0

I am having trouble in Tcl using numbers with leading zeros. I am parsing some numbers that can have leading zeros, such as “0012”, which should be interpreted as the integer “twelve”.

$ tclsh
% set a 8 
8
% set b 08
08
% expr $a - 1
7
% expr $b - 1
expected integer but got "08" (looks like invalid octal number)

What is the best way to handle numbers that might have a leading zeros in Tcl?

On a side note, what would constitute a valid octal number in Tcl, if “08” is an invalid one?

  • 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-13T13:33:06+00:00Added an answer on May 13, 2026 at 1:33 pm

    You’ll want to read Tcl and Octal Numbers at the Tcl wiki. The canonical way is to treat your input as a string and use the scan command to extract the numbers. That leads to this, yes multiline, proc:

    proc forceInteger { x } {
        set count [scan $x %d%s n rest]
        if { $count <= 0 || ( $count == 2 && ![string is space $rest] ) } {
            return -code error "not an integer: \"$x\""
        }
        return $n
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I having trouble in dividing the HTML frames. I have been using the following
Having trouble with some select statements. I have 2 tables. sms_log and sms_messages. sms_log
I having trouble with a simple question : How to have some disabled field
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
Im having trouble using a .NET COM in vb6, It compiles ok and I
Having trouble using Powershell to manipulate IP Restrictions on IIsWebVirtualDir (Virtual Directories). However, i
Having trouble rewriting the name of a flash file: /flash/shell.1257347618.swf (the numbers are a
Having trouble with pattern and replacement. How can I make the replacement echo a
Having trouble figuring out how to impersonate another user while using aspnet_personalization with Windows

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.