From owner-freebsd-bugs@freebsd.org Wed Jan 13 11:49:17 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21B83A80069 for ; Wed, 13 Jan 2016 11:49:17 +0000 (UTC) (envelope-from nibbana@gmx.us) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8A6DB1C5F for ; Wed, 13 Jan 2016 11:49:15 +0000 (UTC) (envelope-from nibbana@gmx.us) Received: from mail.gmx.com ([72.251.118.232]) by mail.gmx.com (mrgmx002) with ESMTPA (Nemesis) id 0MOx4J-1aDX9s2gAJ-006KR6 for ; Wed, 13 Jan 2016 12:49:13 +0100 Date: Wed, 13 Jan 2016 02:50:09 -0900 From: "CK" To: Cc: Subject: dc(1) bugs Reply-To: "CK" X-Mailer: UMail v1.0 Message-ID: <0M8edX-1ZxEjK1XcZ-00wE8S@mail.gmx.com> X-Provags-ID: V03:K0:n3gXVAiWavibMCdhUPss3rySe4WSexh5hYGepVrBUDz7YwgpTcB qoXizh/j829Q14DIOyfkZbU+avBo70GAmoTakfV/ercNfLCXKfMLWmK7lWsYwOlmCC2CN3W QTI7Ec9uvpOTJvLS1O4ncw+jKHqjW7eMfiLXqFTC1y2uqwdSji1xH3TrZlfekYGoY6j9Y6r lD/RhWA0FknaYDZ1rsYbg== X-UI-Out-Filterresults: notjunk:1;V01:K0:O1eIHidyFOg=:JNT/2p5Ntjj0bj9QOsj/cR MT57k7ZcbStuXF4wyZa9NFbjmhMd28eu3fdQhik0ZLB0SIqLtrTcynCBZjQLzIw5NrWOULyFR FaOa/ajgoWdsHpyTDAldZWpABHZlY9kmJ5FtNcZNNX8zBepXaj3aU4ohh/iqQZrab5kSWXWG7 Ud3WOzTvCOvJ24chh068HW+eTNaCzYBQAZAV98dXOgpclaMb6Wh6Ft5uvE6Ly90k2JXTMjPnN KMC3SgncLa2TDIYZ8xCSBWEtqJtDUjXVFZ0eTHPXr1Xm0HHIiTKCSwHdkd7Cp2axDT41fnVvy MWtHS+Yn1gRhZM3G5ZK7YTzDrKJb983FUbugVHNYNwo/OzoTOLY2jFfPbcsYidYwTrdFgcSJi WSbKNLOBl8rBx2Aom8BCc8hbzEN1mpAHyiBnU50M0wL+V81wtJInjYm/yuij6mCq29eQsTFNn V3ZOKt4SfIT7AX2sm9IiV7M4JAILwKrJjUNBXg4xrEup4VLOqAx2xSjbuNIi+1/d7KjOFsaFV 5SIysVqp6ITPWbD8oxc4oCwTxEBfXEqy3TGwEeayhCswEFTDIPpLea8ldhv3wsSnn+36C8dFr FcJuYeXj6BU7tnUXCJ7xPMHMD0uoG4hOQQ6l+dgXO+I64cWk6flAUUbnkHQByN3o7J52dz4Op Xhu7OzrfihVlbPcnGBKSuqCMoaRr94dgEz7uhn23xpY4pZ97jrmM700tG61+YWS7civpZLK7B T7eL3EtXqRmKj2OasIsxIr0OIVy9WDl+lmhp/x/JZBER5RhNfUcUKp9Tpfw= X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2016 11:49:17 -0000 Original posting to freebsd-questions ... FreeBSD-9.3 dc(1) These appear to be bugs to me, but please verify if possible: ##### FIRST ##### $ dc -xe '50k16o16i.1vp' 0 $ dc -xe '50k10o16i.1vp' 0 $ dc -xe '50k10o10i.1vp' [0].31622776601683793319988935444327185337195551393252 This should be telling dc(1): a) scale is 50 (in decimal) digits. b) output in base16, base10, and base10 respectively. c) input will be in base16, base16, and base10 respectively. d) take the square root, and print it to the display. Of course, the 3rd example above is correct, but the first 2? Why 0? ###### SECOND ###### $ dc -xe '50k16o16i.4 2^p' [0].0A $ dc -xe '50k16o16i.0Avp' [0].2C572B0D5A1443EC508B9E24D8DF392750959EE138 This should be telling dc(1): a) scale is 50 (in decimal) digits. b) output in base16, input is now base16. c) square "0.4", and print it to the display (result=0.0A). d) take the square-root of "0.0A", and print it to the display. Of course, the square-root of a squared number should result in the orginal number. But, this is not happening. ##### THIRD ##### $ dc -xe '50k16o16i.4 2^p' [0].0A $ dc -xe '50k16o16i.40 2^p' [0].1000 $ dc -xe '50k16o16i.400 2^p' [0].10000 $ dc -xe '50k16o16i.4000 2^p' [0].1000000 dc(1) is supposed to be precise in the digits it calculates, but here? Something is not right about these results, or so it appears to me. ###### FOURTH ###### $ dc -xe '50k16o16i.1vp' 0 $ dc -xe '50k16o16i.10vp' [0].3EB4F9D9B6D094C33D38373D38777A7D9233A1B0FB $ dc -xe '50k16o16i.100vp' [0].3FBE55183CA5ADC8B39B27C6258E4C7E64338B909F $ dc -xe '50k16o16i.1000vp' [0].400000000000000000000000000000000000000000 Checking the result of the THIRD example, dc(1) is not outputting to the scale specified, and despite having all a scale of 50, they are all giving different results with inputs having a scale of only 1/2/3/4; Something seems broken to me. -- GNU's dc(1) is broken too: Wow! Great! Thanks! I really needed a calculator to do squares and square-roots of hexadecimal fractions, and I use FreeBSD, but their dc(1) is broken too ... http://lists.freebsd.org/pipermail/freebsd-questions/2016-January/269999.html http://lists.freebsd.org/pipermail/freebsd-bugs/2016-January/065825.html I was a little depressed in writing, sorry :) But I am so happy if I can find a working dc(1). Supposedly, it was the first utility, predating even UNIX. A modern computer should have a working calculator - at least, I think so. Thank you so much for your reply, I have some encryption-related software that depends on it. > On Tuesday 12 January 2016 23:05:41 CK wrote: > > > dc (GNU bc 1.06.95) 1.3.95 > > > > $ dc -e '50k16o16i.4vp' > > [0].727C9716FFB764D594A519C0252BE9AE6D00DC9192 > > > > This is not a 50-digit scale. > > It is a 50 digit scale base 10 which is of course shorter base 16. > > > $ dc -e '50k16o16i.727C9716FFB764D594A519C0252BE9AE6D00DC9192 2^p' > > [0].333333333333333333333333333333333325CC2DCA > > > > This is not even close to being the original number: 0.4. > > This appears to be true. I'll investigate why the algorithm is wrong. > > --Phil