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=0.6 required=5.0 tests=BAYES_05,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!apple!bionet!agate!shelby!msi.umn.edu!sctc.com!stachour From: stachour@sctc.com (Paul Stachour) Newsgroups: comp.lang.ada Subject: "Integer" value of a CHARACTER Summary: How can I convert a character to its internal int representation Keywords: conversion cast representation bit-value 'VALUE Message-ID: <1990Nov28.210856.14960@sctc.com> Date: 28 Nov 90 21:08:56 GMT Organization: Secure Computing Technology Corporation List-Id: I have this "simple" problem. I have something that I need its internal representation of. I need this to calculate a checksum or a hash-value or ... I really don't even care what the value is, or plan to do anything neat-o with it. I just need it to be repeatable. In the (simplified) example below, I am trying to get a hash-value from several characters in a string. However, I seem to get problems in doing this. In the example given, I get "constraint-error" on the attempt to do the "conversion". (V_Name is a 60-char string with an OK name in it, the first character is a "c".) What am I doing wrong? How should I be doing it? [Unchecked conversion between an 8-bit character and an integer is not guarenteed either, is it? Or do I work with some particular range of integer?] -- ********************************************************** -- function Hash_Name( The_Name : in V_Name ) return Positive is C: STRING(1..1); begin C(1) := The_Name(1); return POSITIVE'VALUE(C(1..1)); --1 return POSITIVE'VALUE(The_Name(1)); end; -- ********************************************************** -- -- Paul Stachour Secure Computing Technology Corp stachour@sctc.com 1210 W. County Rd E, Suite 100 Arden Hills, MN 55112 [1]-(612) 482-7467