CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Decimal to Binary in Python Code Error

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 21, 2021, 11:01
Exclamation Decimal to Binary in Python Code Error
  #1
New Member
 
Vikash Daga
Join Date: Oct 2021
Location: India
Posts: 1
Rep Power: 0
thebrokenheartcoder is on a distinguished road
I was trying to convert Decimal to Binary, there is no error in the code but while executing I am getting blank, not showing anything. Could someone help me figure out where is the mistake

Code:
def decimalToBinary(ip_val):
    if ip_val= 1:
    # recursive function call
        decimalToBinary(ip_val // 2)
    
    # printing remainder from each function call
    print(ip_val % 2, end = '')
 
# Driver Code
if __name__ == '__main__':
    # decimal value
    ip_val = 24
     
    # Calling special function
    decimalToBinary(ip_val)
I have read this article to understand the concept and tried this.
thebrokenheartcoder is offline   Reply With Quote

Old   October 21, 2021, 13:11
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
As a start, line 2:
Code:
if ip_val= 1:
should be
Code:
if ip_val >= 1:
That should help.
Tobermory is offline   Reply With Quote

Reply

Tags
python


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[blockMesh] blockMesh with double grading. spwater OpenFOAM Meshing & Mesh Conversion 92 January 12, 2019 10:00
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 10:17
[swak4Foam] installing funkySetFields igo OpenFOAM Community Contributions 1 November 20, 2012 21:16
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 07:42
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 07:25


All times are GMT -4. The time now is 07:32.