From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!Xl.tags.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 29 Jan 2015 11:36:20 -0600 From: montgrimpulo Subject: Integer to String Newsgroups: comp.lang.ada X-UserIpAddress: X-InternalId: 62bedc51-f1d0-4d3b-9707-326d5521642d Message-ID: Date: Thu, 29 Jan 2015 11:36:20 -0600 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-g2oJsyPDeL1ybgmUMKLurxZnFQ0BLZhgJ/6id/Myg7DEbu7bGQtxFoXo92eB7G89bs0e4sv4MQR8e5b!5YehUXSOM0bpMzdcaK2M+iF4bWK3Tx1rtw8H0a+YDIxIGoTepbQrdPM/wFO5ht3urCFYUqlNbHyp!2Z8= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1881 Xref: news.eternal-september.org comp.lang.ada:24798 Date: 2015-01-29T11:36:20-06:00 List-Id: Hi, I want to solve in Ada: from Integers (1,2,3,4,5,6) to String "123456" and then to Integer 123456, to avoid multiplications and additions. I tried with some Attributes and solved the second part. with Ada.Text_IO; use Ada.Text_IO; procedure ItoS is package I_IO is new Integer_IO (Integer); use I_IO; num : integer ; char : character ; str : String(1..6); begin num := 7; char := character'Val(num); New_Line;Put("num = ");Put(num); New_Line;Put("char= ");Put(char); char:='7'; num:=character'Pos(char); New_Line(2);Put("char= ");Put(char); New_Line;Put("num= ");Put(num); str:="123456"; num:=Integer'Value(str); New_Line(2);Put("num= ");Put(num); (20) str:=Integer'Image(num); New_Line;Put("str= ");Put(str); end ItoS; However, the outcome is : num = 7 char= char= 7 num= 55 num= 123456 raised CONSTRAINT_ERROR : itos.adb:20 length check failed.