CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Decimal to Binary in Python Code Error

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Tobermory

LinkBack Thread Tools Search this Thread Display Modes
Old   October 21, 2021, 10:01
Exclamation Decimal to Binary in Python Code Error
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

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
I have read this article to understand the concept and tried this.
thebrokenheartcoder is offline   Reply With Quote

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:00
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 09:17
[swak4Foam] installing funkySetFields igo OpenFOAM Community Contributions 1 November 20, 2012 20:16
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 06:42
CGNS lib and Fortran compiler manaliac Main CFD Forum 2 November 29, 2010 06:25

All times are GMT -4. The time now is 01:30.